![]() |
|
|
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 |
| Replacing nulls using sed | novice1324 | Shell Programming and Scripting | 7 | 02-27-2008 03:56 AM |
| help in replacing ?? | zedex | Shell Programming and Scripting | 5 | 08-31-2007 02:45 AM |
| Replacing in SED | superprogrammer | Shell Programming and Scripting | 8 | 07-11-2006 03:33 AM |
| replacing corrupt /tmp dir.. | moxxx68 | UNIX for Advanced & Expert Users | 6 | 05-28-2005 07:58 PM |
| replacing \n by \r\n | crashnburn | UNIX for Dummies Questions & Answers | 3 | 11-24-2003 03:49 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
replacing with `pwd`
Hi E(uni)xperts,
I have a file in which I need to replace some text with the current path of the execution. meaning.. if I am running from /user/oldtrash/scripts and the file contains "this is ur directory current_dir" then I should see the file content as "this is ur directory /user/oldtrash/scripts" Any ideas? Thanks, OldTrash |
|
||||
|
Hi Optimus,
Thanks for the reply. I forgot to mention my trials with sed and perl.. I tried old>sed -e "s/current_dir/`pwd`/" < old_file > new_file sed:command garbled: /current_dir//user/oldtrash/scripts/ old>perl -e "s/current_dir/`pwd`/" < old_file > new_file Bareword found where operator expected at -e line 1, near "s/current_dir//user" syntax error at -e line 1, near "s/current_dir//user" Bareword found where operator expected at -e line 1, near "Oldtrash" (Missing operator before Oldtrash?) Execution of -e aborted due to compilation errors. OldTrash |
|
||||
|
i thought you ment you already had in place of current_dir teh pwd command.
didnt know you were trying to sub it on the fly. dont use the forward slash in your sed command choose another metachar like pipe. ie: sed "s|current_dir|`pwd`|" <filename> that works on my sys |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|