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
you answered your own question in the subject of this thread.
just make that text file executable.
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
pressy
April 9, 2004, 5:28pm
4
why don'T you use the shell variable:
$PWD
?
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
Thanks Optimus,
It worked.
Thanks Pressy for looking into this.