How to edit multiple files in several sub directories?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • laxman
    New Member
    • Apr 2012
    • 1

    How to edit multiple files in several sub directories?

    I want to add particular text to multiple files in each directories

    Directories such as d1,d2,d3 so on. Each directory contains a unique file name named print.txt but contains different content. I want to add a particular text to each of the text file. How to add the text?
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    Code:
    for f in `ls d?/print.txt`; do echo "some text" >>$f; done

    Comment

    • vakula
      New Member
      • Dec 2012
      • 3

      #3
      Code:
      find . -name "print.txt"|xargs perl -i.bak  -lne 'print;print "some text" if eof'
      taken from <link removed>
      Last edited by Rabbit; Dec 31 '12, 08:38 AM. Reason: Link to outside site removed.

      Comment

      • Luuk
        Recognized Expert Top Contributor
        • Mar 2012
        • 1043

        #4
        @vakula: This thread is 6, no 8!!, months old...... ? !!!

        Comment

        Working...