![]() |
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 |
| 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 !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| replacing a number with random variable inside shell script | user_prady | Shell Programming and Scripting | 3 | 09-11-2007 02:44 AM |
| help in replacing ?? | zedex | Shell Programming and Scripting | 5 | 08-31-2007 01:45 AM |
| replacing variable values in all files in directories | newtoshell | Shell Programming and Scripting | 3 | 12-30-2005 04:11 PM |
| Replacing set of characters with a value of a variable | prekida | Shell Programming and Scripting | 1 | 07-26-2005 08:14 PM |
| Replacing pattern in variable | videsh77 | Shell Programming and Scripting | 1 | 05-26-2005 02:11 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Replacing $ in variable
hi
I have a variable like k=$DESTDIR/$PKG/$VERSION I want to replace each $ in string k with say "XXX". so that k becomes like this "XXXDESTDIR/XXXPKG/XXXVERSION" when I use echo $k | sed -e "s/\$/XXX" it actually passes expanded of variables $DESTDIR, $PKG and $VERSION to sed. Please help. Ashish |
|
||||
|
Replacing "$" in variable
hi
I have a variable like k=$DESTDIR/$PKG/$VERSION I want to replace each $ in string k with say "XXX". so that k becomes like this "XXXDESTDIR/XXXPKG/XXXVERSION" when I use echo $k | sed -e "s/\$/XXX" it actually passes expanded of variables $DESTDIR, $PKG and $VERSION to sed. Please help. |
|
||||
|
probably the variable k is not formed correctly. Can you try echo $k and see if you get $DESTDIR/$PKG/$VERSION ? Are you forming the variable k like this : k="\$DESTDIR/\$PKG/\$VERSION" ? if so, the sed command works as expected.
|
|
||||
|
$DESTDIR/$PKG/$VERSION is coming from a read only file to k while reading.
|
|
||||
|
I am using while loop like
while read k .....// if $DESTDIR is present in k then go to next line in file because DESTDIR is not defined . else use value of k as it is it may be $PKG/$VERSION as these variable are defined. ..... done < $file |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|