Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sed in BASH

Status
Not open for further replies.

krava

Programmer
Jun 4, 2007
48
YU
Hi all,

I am trying to enable this BASH function which use sed command


function cdc{
eval $x=\"$(sed 's_\\_/_g' $1)\"
cd $x
}

USAGE: cdc c:\users\us2\



Aim is to replace c:\users\us2\ into c:/users/us2/ to be executable by Cygwin. I am not sure why this does not work. Any idea?


Thanks
Krava


 
It doesnt work because sed is trying work on the contents of a file called $1
Try
Code:
function cdc{
    eval $x=\"$(echo $1 | sed 's_\\_/_g')\"
    cd $x
}

Ceci n'est pas une signature
Columb Healy
 
thanks for reply

this is the output I get:

bash: /home/ovince/.bashrc: line 112: syntax error near unexpected token `eval'
bash: /home/ovince/.bashrc: line 112: ` eval $x=\"$(echo $1 | sed 's_\\_/_g')\"'


The same error message I got for my version
 
This works for me
Code:
function cdc() { cd $(echo $1 | sed 's_\\_/_g'); }

Ceci n'est pas une signature
Columb Healy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top