![]() |
|
|
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 |
| How to replace word in CSV | kinmak | Shell Programming and Scripting | 4 | 04-24-2008 02:24 PM |
| Perl: Search for string on line then search and replace text | Crypto | Shell Programming and Scripting | 4 | 01-04-2008 10:24 AM |
| Replace word. | abu_hassan | SUN Solaris | 2 | 03-04-2007 05:14 PM |
| Perl script assistance; paste word into external command | bru | Shell Programming and Scripting | 10 | 02-23-2007 04:04 AM |
| how to replace a word with another | rkrgarlapati | Shell Programming and Scripting | 1 | 07-24-2006 08:42 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
sed search and replace word assistance...
Hi,
I am trying to write a shell script designed to take input line by line by line from a file with a word on each line for editing with sed. Example file: 1.ejverything 2.bllown 3.maikling 4.manegement 5.existjing 6.systems My design currently takes input from the user, and stores it in a variable (linenum) which is then used in sed as the line number. I have, echo "Which line number" read linenum And then use $linenum in sed as the line number in the file, ex sed '"$linenum"i\ > FINDSTRING\ > REPLACESTRING > ' foo > foo.old I haven't got the above to work so far. I guess my question is, can you use variables in a sed command line? If so how? I also saw the option of using a loop to accomplish the job somewhere as shown below... #!/bin/bash for in $fl; do mv $fl $fl.old sed 's/FINDSTRING/REPLACESTRING/g' $fl.old > $fl rm -f $fl.old done Please help! ![]() |
![]() |
| Bookmarks |
| Tags |
| shell script, shell scripting, unix scripting, unix scripting basics |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|