SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: command

  1. #1
    SitePoint Addict
    Join Date
    Jun 2008
    Posts
    205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    command

    How to search for the file in the directory which has the string "ABC" and replace the string "ABC" with "XYZ" in all the files.


    find . -type f -exec grep 'ABC' -print {} \;

  2. #2
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    for file in `grep -lr ABC ./*`; do
      sed 's/ABC/XYZ/g' $file >/tmp/$$ && mv /tmp/$$ $file
    done


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •