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.
You will get an error if the variable $TFTP_ROOT_PATH contains any unescaped '/'
If so, try using a different delimiter for the sed s command e.g.
s# # # instead of s/ / /
or escape all the '/' in $TFTP_ROOT_PATH before using it in sed:-
I am almost new to linux. can u plz explain me that line.
thx
That is a variable, He is using a system variable with special charaters and makeing another variable without them so that sed can read it, since sed wants special charters to be proceeded with a "\".
I hope that didnt add more confusion to your question
thanks lads. changing the variable helped.
I see the confusion on my part now. I was dealing with $ sign but actually forgot that it is replaced when sed is dealing with it.
However, this line:
Quote:
TFTP_ROOT_PATH_esc=${TFTP_ROOT_PATH//\//\\/}
What does it actually do? Say if my variable $VAR has following data:
echo $VAR
/usr/local/share/images
What are all these slashes doing? Is there a description? Just curious.
I get that, but why so many //\//\\/? I mean, it must have some logic somewhere.
If it would have been $VAR_esc=${VAR/\/} I could have understood say it is taking / -> \/ but this is not the case. so why '//\//\\/'?
You might be interested in downloading the "Advanced Bash Scripting Guide" from the www.tldp.org website. It consists entirely of commented examples that you can try yourself, making it easier to learn even though it covers advanced subjects.
1. / indicates the beginning of the pattern
2. / indicates that all the patterns should be replaced
3. \/ will get evaluated to \
4. / indicates the end of the pattern
5. \\/ will become \/ which is the string.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.