Unix/Linux Go Back    



Find and Replace in multiple files (Shell script)

Shell Programming and Scripting




Kindly Note - This is a Single User Post by Forum Member asifraj Regarding:
Find and Replace in multiple files (Shell script).
Please Follow The Primary Link Above to View the Full Discussion.

   
Old Unix and Linux 08-20-2002   -   Original Discussion by jatins_s
asifraj's Unix or Linux Image
asifraj asifraj is offline
Registered User
 
Join Date: Aug 2002
Last Activity: 17 October 2003, 10:33 PM EDT
Location: India
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
hi,

try this,

cd <your_folder>
ls > out.sh

vi out.sh

:%s/^/perl -pi -e 's\/ABCD\/DCBA\/' /

save and exit

sh out.sh

and bingo....

"perl -pi -e 's/abcd/dcba/' filename" will basically do the substitution and listing all the files in a file then prepending this string in front of each filename, will produce a shell script out.sh which would run this perl command on each of the files.

hope it helps
asif