![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need Replacement for sed | dbsurf | Shell Programming and Scripting | 0 | 01-25-2008 02:47 PM |
| Regarding Replacement | rajx | UNIX for Dummies Questions & Answers | 2 | 05-22-2007 06:19 AM |
| Replacement of Delimiter | panknil | Shell Programming and Scripting | 3 | 05-14-2007 04:35 AM |
| cpu replacement. help | IMPTRUE | UNIX for Dummies Questions & Answers | 3 | 07-25-2003 05:40 AM |
| global replacement | Babu | UNIX for Dummies Questions & Answers | 2 | 07-04-2001 06:02 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Replacement using sed
Hi
I have the following file that i need to run a sed command on 1<tab>running 2<tab>running 3<tab>running 4<tab>running I want to be able to replace a line i.e the second one with '2<tab>failed'. As the first number is unique that can be used to search for the relevant line (using ^2 i guess). So i want the output to be 1<tab>running 2<tab>failed 3<tab>running 4<tab>running Thanks, |
| Forum Sponsor | ||
|
|
|
|||
|
Thanks.
sed '/^2/s/running/failed/' testfile works great. I also have the scenario where I have the following 1<tab>sleeping<tab>100 and I want to replace the 'sleeping 100' part with 'running'. How do I match a word and the remainder of the line? |
|
||||
|
zazzybob,
Yes, you're right. From man awk... Quote:
|
||||
| Google The UNIX and Linux Forums |