Results 1 to 3 of 3

Thread: script grep a pattern and replace a specific pattern

  1. #1
    Junior Member
    Join Date
    Aug 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default script grep a pattern and replace a specific pattern

    Hi,

    I'm trying to find out a speicifc text in all files in a directory and in sub directories, And also I want to replace the matched files by another pattern. How can I achieve this?

    for exmaple I'm searching for a text aaabbb in all files and I want to replace it by cccddd. Could anyone help me on this?

  2. #2
    Senior Member
    Join Date
    Aug 2011
    Posts
    458
    Thanks
    0
    Thanked 62 Times in 58 Posts
    Rep Power
    10

    Default

    hi,

    Code:
    find ./ -type f -execdir 'sed -i "s/aaabbb/cccddd/g"' \;
    man sed
    man find
    !
    A problem clearly stated is a problem half solved.

  3. #3
    Junior Member
    Join Date
    Aug 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    Quote Originally Posted by Watael View Post
    hi,

    Code:
    find ./ -type f -execdir 'sed -i "s/aaabbb/cccddd/g"' \;
    man sed
    man find
    !
    I'm trying the same with a for loop and sed command. I should have mentioned it before. But the patters im searching is very complex and lengthy one. Itconsists of lots of special symbols like {}[]' " ; : ..... so getting some error. How can I replace such a complex patern.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. String Pattern Using grep Command
    By numerouno in forum Shell scripting
    Replies: 1
    Last Post: 27th May 2013, 10:33 PM
  2. Expect Script - Pattern Matching Trouble
    By rmsagar in forum Shell scripting
    Replies: 0
    Last Post: 13th January 2013, 03:45 PM
  3. [Solved] Sed match multiple UPPERCASE pattern and replace it
    By meta in forum Shell scripting
    Replies: 4
    Last Post: 20th July 2010, 09:18 PM
  4. Replies: 1
    Last Post: 3rd September 2009, 06:07 AM
  5. pattern search with numbers
    By mercuryshipz in forum Coding in General
    Replies: 0
    Last Post: 15th February 2008, 12:16 AM

Tags for this Thread

Posting Permissions

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