vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| On Thu, Mar 04, 2004, Kyle wrote: >hi >need a little help >I would like to search a group of files for text and replace that text with >another text. >ex. >search for numformat 44 and replace with numformat . You can do this with sed, awk, perl, or other tools with a bit of work, or use the GNU shtool, and to it trivially: shtool subst \ -e 's/numformat 44/numformat/g' \ *.txt Bill -- INTERNET: bill@Celestial.COM Bill Campbell; Celestial Software LLC UUCP: camco!bill PO Box 820; 6641 E. Mercer Way FAX: (206) 232-9186 Mercer Island, WA 98040-0820; (206) 236-1676 URL: http://www.celestial.com/ ``During times of universal deceit, telling the truth becomes a revolutionary act.'' --George Orwell |
| |||
| Bill Campbell typed (on Thu, Mar 04, 2004 at 11:02:40AM -0800): | On Thu, Mar 04, 2004, Kyle wrote: | >hi | >need a little help | >I would like to search a group of files for text and replace that text with | >another text. | >ex. | >search for numformat 44 and replace with numformat . | | You can do this with sed, awk, perl, or other tools with a bit of | work, or use the GNU shtool, and to it trivially: | | shtool subst \ | -e 's/numformat 44/numformat/g' \ | *.txt Sounds good, but the ftp repositories for shtool only go to 1.5.4, and there are missing 1.6.x entries. I just grabbed the latest one, and 'subst' is not a sub-command in 1.5.4. -- JP |
| |||
| On Thu, Mar 04, 2004, Jean-Pierre Radley wrote: >Bill Campbell typed (on Thu, Mar 04, 2004 at 11:02:40AM -0800): >| On Thu, Mar 04, 2004, Kyle wrote: >| >hi >| >need a little help >| >I would like to search a group of files for text and replace that text with >| >another text. >| >ex. >| >search for numformat 44 and replace with numformat . >| >| You can do this with sed, awk, perl, or other tools with a bit of >| work, or use the GNU shtool, and to it trivially: >| >| shtool subst \ >| -e 's/numformat 44/numformat/g' \ >| *.txt > >Sounds good, but the ftp repositories for shtool only go to 1.5.4, and >there are missing 1.6.x entries. I just grabbed the latest one, and >'subst' is not a sub-command in 1.5.4. We're running shtool-1.6.2 here under the OpenPKG package management system. I've extracted the tarball from the source RPM, and it's available on our ftp site: ftp://ftp.celestial.com/private/ftp....l-1.6.2.tar.gz Bill -- INTERNET: bill@Celestial.COM Bill Campbell; Celestial Software LLC UUCP: camco!bill PO Box 820; 6641 E. Mercer Way FAX: (206) 232-9186 Mercer Island, WA 98040-0820; (206) 236-1676 URL: http://www.celestial.com/ When a place gets crowded enough to require ID's, social collapse is not far away. It is time to go elsewhere. The best thing about space travel is that it made it possible to go elsewhere. -- Robert Heinlein |
| ||||
| Kyle wrote: > hi > need a little help > I would like to search a group of files for text and replace that text with > another text. > ex. > search for numformat 44 and replace with numformat . > thanks in advance > Kyle > > > This may be close ... perl -p -i.bak -e 's/numformat 44/numformat ./g' \ `grep "numformat 44" *.txt` or maybe man find find <dir> -name "filespec" -exec <see above> or use ksh & sed There are many variations. The OReilly book "Unix Power Tools" is a good starting point. Any Unix FAQ probably covers this. |