Skip to Content
  • +31 653-919-302
Cafayate.Net
  • 0
  • 0
  • Sign in
  • Nederlands English (US) Español (AR)
  • Contact Us
  • Home
  • Blog
  • Jobs
  • Contact us
Cafayate.Net
  • 0
  • 0
    • Home
    • Blog
    • Jobs
    • Contact us
  • +31 653-919-302
  • Nederlands English (US) Español (AR)
  • Sign in
  • Contact Us

SED rename

  • All Blogs
  • Tech Blog
  • SED rename
  • March 5, 2021 by
    Administrator

    A very simple solution: replace in all *.txt files in folder string_1 with string_2:

    sed -i 's/string_1/string_2/g' *.txt

     

    https://askubuntu.com/questions/84007/find-and-replace-text-within-multiple-files

     

    Here I use sed to replace every occurrence of the word “cybernetnews” with “cybernet” in every file with the extension, c, in the directory, /home/user/directory/.

    find /home/user/directory -name \*.c -exec sed -i "s/cybernetnews/cybernet/g" {} \;
    

    A more generic variation where you search recursively from the directory of execution and operate on only regular, readable, writeable files:

    find ./ -type f -readable -writable -exec sed -i "s/cybernetnews/cybernet/g" {} \;
    in Tech Blog
    Using LXD remote with ssh port forward

    Designed for companies

    We are a team of passionate people whose goal is to improve everyone's life through disruptive products. We build great products to solve your business problems. Our products are designed for small to medium size companies willing to optimize their performance.

    Get in touch

    Plantexel
    Pedernera
    Salta Capital 
    Argenina

    • +31 653-919-302
    • [email protected]
    Follow us
    Copyright © Plantexel
    Nederlands | English (US) | Español (AR)