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.
Search And Replace With Sed
Name: James Gordon Date: September 18, 2002 at 23:55:14 Pacific OS: Sun Solaris CPU/Ram: Unknown
Comment:
Hi,
I intend to do a search and replace for specific words for files under a directory (inclusive of subdirectories).
I know how to do that file by file using sed and redirect it to the original file. But now, I need to search for multiple files and update accordingly.
Name: tom z. Date: September 19, 2002 at 03:14:46 Pacific
Reply:
Maybe a for loop with a variable for your filenames generated by ls?
foreach file (`ls`) do whatever $file done
0
Response Number 2
Name: David Perry Date: September 19, 2002 at 05:31:38 Pacific
Reply:
for pattern in "string1" "string2" ; do for file in `find /full/path/root/to/search/ -exec grep -l $pattern {} \;` ; do ls -l $file ; sed -e 's/$pattern/newpattern/' $file > $file.tmp mv $file.tmp $file done ; done | mail user@domain.com
Summary: Hi, Can anyone help me with the command to do the following search and replace in the following files: Files: file1 file2 file3 Search String: "GET /thisfile?id= Replace String: "GET /thisfile?source=...
Summary: Is it possible to do search and replace in unix Like : s/some date/current date/g some date and current date both are in same format (dd/mm/yyyy hh:mm:ss) My requirement is : I am having a variable w...
Summary: Hi, I have a problem in my requirement. I have a file called 1000.log which is basically an xml for an internet order at our site. The xml will contain a tag as given below. <doc_no>545454545454545...