ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
my_path=root\/test
find `pwd` | sed -e 's/^.*'"$my_path"'/./'
It does not work.
error occur
if I take out the single quotation mark like that, no error occur.
find `pwd` | sed -e 's/^.*"$my_path"/./'
however, the sed will not replace the pre-fix "root/test" to "."
What is the different between single quotation mark and double quotation mark in sed?
It's the shell, not sed, that is parsing the quotes. Double quotes allow variable interpolation, single quotes don't. There's a fair bit of info in the bash man page about it (I'm assuming your shell is bash).
You could also use a different separator for the substitute command in sed - then you shouldn't need to quote the variable. I'm not at a box I can test that on at the moment though.
It's the shell, not sed, that is parsing the quotes. Double quotes allow variable interpolation, single quotes don't. There's a fair bit of info in the bash man page about it (I'm assuming your shell is bash).
You could also use a different separator for the substitute command in sed - then you shouldn't need to quote the variable. I'm not at a box I can test that on at the moment though.
thanks. yes, it is bash shell.
how do define another separator for the command in sed?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.