![]() |
|
|
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 |
| problem with tr command | ravi raj kumar | UNIX for Advanced & Expert Users | 2 | 07-02-2007 07:41 AM |
| problem with mv command | dsravan | Shell Programming and Scripting | 7 | 06-07-2007 12:32 PM |
| where is the problem in my sed command.... | P_W | UNIX for Dummies Questions & Answers | 5 | 04-20-2007 10:48 PM |
| problem with dd command or maybe AFS problem | Anta | Shell Programming and Scripting | 0 | 08-25-2006 11:10 AM |
| ls command problem | buckhtr77 | SUN Solaris | 2 | 12-06-2005 04:16 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
problem in sed command
Hi,
i have a script to replace a string. $ cat List.txt /DIR1/DIR2/DIR3/abcdefgh /DIR1/DIR2/DIR3/abcd /DIR1/DIR2/DIR3/abcdefghijk /DIR1/DIR2/DIR3/xyz $ ind=`/DIR1/DIR2/DIR3/abcd` $ replace=`#/DIR1/DIR2/DIR3/abcd` $ sed "s|$find|$replace|g" List.txt>cat NewList.txt The aim of above 3 lines are to modify the line /DIR1/DIR2/DIR3/abcd as #/DIR1/DIR2/DIR3/abcd. but the its replacing the 3 lines as bellow $ cat NewList.txt #/DIR1/DIR2/DIR3/abcd #/DIR1/DIR2/DIR3/abcdefgh #/DIR1/DIR2/DIR3/abcdefghijk /DIR1/DIR2/DIR3/xyz i has to replace only one line. help me in solving this problem. Thanks in advance. ~Saravana.. |
|
||||
|
Backticks is used to set the result of a command to a variable not to assign a value to a variable, use quotes instead: Code:
find="/DIR1/DIR2/DIR3/abcd" replace="#/DIR1/DIR2/DIR3/abcd" sed "s/$find/$replace/" List.txt > NewList.txt |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|