![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Replace Entire line if any part matches regexp | Cocoabean | Shell Programming and Scripting | 6 | 09-14-2008 03:02 PM |
| replace part of single string in a file | nixjennings | UNIX for Dummies Questions & Answers | 2 | 08-06-2008 09:47 PM |
| regarding replace a part of a string | madhu_aqua14 | UNIX for Dummies Questions & Answers | 7 | 08-04-2008 10:07 AM |
| Find and replace a part of the word in Shell | mihirk | Shell Programming and Scripting | 3 | 06-25-2007 03:08 AM |
| using sed to replace a part of string | csejl | Shell Programming and Scripting | 6 | 01-12-2004 11:48 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Replace part of a line with sed/awk
Hello
I have a document and in this document I have several occurrence of "VAR == xxxxxxx" and xxxxx can be anything. I don't know what it is. I want to replace the 'xxxxx's with something I know. What I know however, is the line numbers of the VAR =='s in the file. How can I replace the xxxx's with awk or sed? Can someone please help me out here? Thanks Ali |
|
||||
|
re: Replace part of a line with sed/awk
i tried to simulate your scenario.. so created an input file as below by the name inputfile.txt
------------- var1=shishir var2=shishir var1=shishir var2=shishir var3=shishir ------------ the sed script to replace the "shishir" with "srivastava" in "var1=shishir" at line#3 is as follows sed '3 s/var1=[a-z][a-z]*/var1=srivastava/' and the output is as follows: ------------- var1=shishir var2=shishir var1=srivastava var2=shishir var3=shishir ------------ I think this is what you were looking at.. thnx Shishir srivastava |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|