Computing.Net > Forums > Unix > change string in multiple file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

change string in multiple file

Reply to Message Icon

Name: plastic_tree
Date: March 8, 2003 at 03:54:23 Pacific
OS: RH linux 8.0
CPU/Ram: 1.8 P4/512mb
Comment:

hello, may i know how can i find and change string in multiple file...i had refer some of the post here .. but found that all is about find and change string in a file only..let say i want to change all occurences of the string 'hei' to 'hello' in only the file with extension .txt....how i can do that.....thanks in advance...



Sponsored Link
Ads by Google

Response Number 1
Name: David Perry
Date: March 8, 2003 at 09:00:45 Pacific
Reply:

#/bin/ksh
for file in `find . -name '*.txt' -type f -print` ; do
echo $file
sed -e 's/hei/hello/' $file > $file.tmp
mv $file.tmp $file
done


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: change string in multiple file

Find and Change String in File www.computing.net/answers/unix/find-and-change-string-in-file/4628.html

Adding a new string in a file www.computing.net/answers/unix/adding-a-new-string-in-a-file/8060.html

How to trim the string in the file? www.computing.net/answers/unix/how-to-trim-the-string-in-the-file/7703.html