How To Escape $ Dollar Sign In Linux
RegisterLogin
How To Escape $ Dollar Sign In Linux
Post Description: I Will Show You How You Can Escape The Dollar Sign $ In A Linux Shell Command
Tags: How, To, Escape, Dollar, Sign, In, Linux, quotes, programming, unix, escaping, single, quote, double
This Post Was Posted On Feb 02, 2010 By Webune Support #3101
Post Description: I Will Show You How You Can Escape The Dollar Sign $ In A Linux Shell Command
Tags: How, To, Escape, Dollar, Sign, In, Linux, quotes, programming, unix, escaping, single, quote, double
This Post Was Posted On Feb 02, 2010 By Webune Support #3101
How To Escape $ Dollar Sign In Linux by Webune Support
do you have a command that you use the dollar sign ($) and you want to display the actual $ dollar sign instead of the variable value, lets say for example you have this command where you want to find and replace values in a file
this is how our expenses.txt file looks like:
expenses.txt
Marry Jones: $455.22
Joe Smith: $255.00
John Maks: $655.55
Joe Smith: $255.00
John Maks: $655.55
ok, lets say we want to replace the value of Marry's salary from $455.22 to $500.00 we can use this command:
awk '{gsub(/\$455.22/, "$500.00", $0); print > FILENAME}' expenses.txt
that will change to:
expenses.txt
Marry Jones: $500.00
Joe Smith: $255.00
John Maks: $655.55
Joe Smith: $255.00
John Maks: $655.55
hope that helps
so basically if you want to escape the $ character in unix, just add the \ slash before or you might get a message the looks like this:
awk: warning: escape sequence `\$' treated as plain `$'
Leave Your Comments
Related Pages: [Add Your Website]
Post New Topic
edward
#3655 1
let me give you some examples, so you can see for yourself, try these commands and the what the output looks like:
echo $path
echo "$path"
echo '$path'
you will be surprise to know that when you use the single quotes, it doesnt display the value of $path variable, but instead, it prints the actual word $path
hope that helps. my name is edward, i am from the country of el salvador.
el salvador is a little country in central america. its quite and peaceful, yet it feels like paradise in the tropics. we have a computer club here. join us
echo $path
echo "$path"
echo '$path'
you will be surprise to know that when you use the single quotes, it doesnt display the value of $path variable, but instead, it prints the actual word $path
hope that helps. my name is edward, i am from the country of el salvador.
el salvador is a little country in central america. its quite and peaceful, yet it feels like paradise in the tropics. we have a computer club here. join us
Mar 29, 2010 Reply Report abuse
gander
#3546 2
i think you can space by like this options:
\$variable
'$variable'
"'$variable'"
$$variable
which one works?
\$variable
'$variable'
"'$variable'"
$$variable
which one works?
Mar 02, 2010 Reply Report abuse
©2011 Webune Forums - Mon Dec 19, 2011 1:13 am
Powered by: Webune Forums V3
Powered by: Webune Forums V3