Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help to modify a file --- sed question I guess

Status
Not open for further replies.

g2345c

Technical User
Jun 23, 2004
22
US
hi,
How do I do this?
i want to search entire file foo.txt for string that started with "*one;twothree". Then see if that string contain string "FOO" or not. if Not Replace the first white-space with "FOO"

sed '/"*one;twothree/[HOW DO I CHECK FOR FOO HERE]s/ /FOO /' foo.txt

thanks
 
Have you tried something like this ?
sed -e '/"\*one;twothree.*FOO/b' -e'/"\*one;twothree/s/ /FOO /' foo.txt



Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi,
Try and it doesn't work. Please help

linuxbuild : /home/hb >more test.sh
#!/bin/sh
sed -e '/"\*one;twothree.*FOO/b' -e'/"\*one;twothree/s/ /FOO /' foo2.txt

linuxbuild : /home/hb >more foo2.txt
hb
test
*one;twothree

linuxbuild : /home/hb >./test.sh
hb
test
*one;twothree
linuxbuild : /home/hb >
 
No need of the " in the pattern ?
So, you may try this:
sed -e '/\*one;twothree.*FOO/b' -e'/\*one;twothree/s/ /FOO /' foo2.txt


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Works great .. Thanks for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top