how to get $1 parameter in ~/.bashrc

Hi,

i am trying to convert windows path to linux and do some action on equivalent mounted one for the same in linux.

echo '\\server1\source\path\needed_files' | sed -e 's!\\!/!g' | sed -e 's!^//!/!' | sed -e 's!\(/server1/source/path\)\(.*\)!/home/$USER/mount/server1\2!'

output:

/home/$USER/mount/server1/needed_files

i can change directory to output. However , i couldnt make it to work when i use it in ~/.bashrc inside function.

win2linx () { 
echo '$1' | sed -e 's!\\!/!g' | sed -e 's!^//!/!' | sed -e 's!\(/server1/source/path\)\(.*\)!/home/$USER/mount/server1\2!'
}

i ran ,

$ win2linx \\server1\source\path\needed_files
$ $1 

what has to be changed to get $1 value , i could not use "" it ignores \ in paths.

I appreciate your suggestions .

???

$ a='\\some\where \a\n\t'
$ echo "$a"
\\some\where \a\n\t

You should call your function so:

win2linx '\\server1\source\path\needed_files'

and use double quotes around $1.

hi,
it works as expected.
Any other possibility to modify the code to call a function with just path ie,without single quotes?

would like to run :

win2linx \\server1\source\path\needed_files
echo \\\\server1\\source\\path\\needed_files

But why? :confused:

hi,
excuses, if i was not clear.

i get a path from windows machine so i do copy from windows and paste the path in linux terminal . i do not want to edit any except calling function.

so from terminal, i need to type like this which is easy !!!

 $ win2linx <path>

i don't want to inform the user to put single quotes beginning and end of the path ie call the function as

 $ win2linx '<path>' 

No way as a command argument. But you can add to your bash function something like this:

read -r -p'Enter a path: ' path
echo "$path"