LinuxAnswers - the LQ Linux tutorial section.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


Search this Thread
Old 03-10-2009, 01:56 AM   #1
Registered: Dec 2004
Posts: 92

Rep: Reputation: 15
Question how to stop parsing shell variables in bash script inside cat area?

cat << EOF >>/tmp/test
test `hostname` = "vm20" || return
expected content of /tmp/test:
test `hostname` = "vm20" || return

actually get:
test vm20 = "vm20" || return

further more, if there are variables like "$#,$a" inside the cat area they all will be parsed and replaced by their value in current shell.

how to stop this kind of parsing inside the cat area?
Old 03-10-2009, 03:34 AM   #2
Registered: Feb 2006
Distribution: Fedora
Posts: 341
Blog Entries: 3

Rep: Reputation: 38
You can escape the backticks using '\' to stop bash from expanding it. e.g.
 test \`hostname\` = "vm20" || return
The same holds for other things like $variable: use \$variable instead.
Old 03-10-2009, 07:44 AM   #3
Registered: Dec 2004
Posts: 92

Original Poster
Rep: Reputation: 15
got it, thanks.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash Script Help - Trying to create a variable inside script when run. webaccounts Linux - Newbie 1 06-09-2008 03:40 PM
grep and assign it's output to variables inside script itself problem xxx_anuj_xxx Programming 3 09-23-2007 12:24 AM
Parsing a File in a Bash Script TGWDNGHN Programming 4 12-02-2005 03:38 PM
(shell script) string parsing kuru Programming 4 09-12-2005 08:59 PM
File Parsing using a Shell Script yasir15 Programming 5 08-22-2003 01:17 PM

All times are GMT -5. The time now is 02:26 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration