Back-Quote in a variable

Discussion of programming on Linux, including shell scripting, perl, python, c/c++, mono, java. Whatever tickles your fancy.
Post Reply
mudasir
Captain
Posts: 565
Joined: Tue Oct 17, 2006 5:23 am
Location: Dubai
Contact:

Back-Quote in a variable

Post by mudasir »

AOA,

Dear LP Members,

I am a bit confused. I am creating a script using BASH shell in which i need to append some text to another file and that text has to be closed in with backquotes(`).

Code: Select all


file=/firewall/mrtg/ids.ips
dir=/firewall/mrtg/cfgs
shdir=/firewall/mrtg/scripts

cat $file | while read ids
do
id=`echo $ids | awk '{print $2}'`
ip=`echo $ids | awk '{print $1}'`
touch $dir/$IP.cfg
echo "Target[tc.class]: $shdir/$IP.sh" >> $dir/$IP.cfg
done
Now the above code is working fine, but missing one thing in the file in which it is being appended, the "$shdir/$IP.sh" should be appended with backquotes at the start and at the end. like this

`/firewall/mrtg/scripts/172.16.10.15.sh`
but it is not i am unable to set these backquotes. it is being appended like

/firewall/mrtg/scripts/172.16.10.15.sh
without backquotes.

Please help me out in setting up these backquotes.
Kind Regards
Mudasir Mirza (RHCE)
(+971)55-1045754
http://www.crystalnetworks.org
http://www.diglinux.com
lambda
Major General
Posts: 3452
Joined: Tue May 27, 2003 7:04 pm
Location: Lahore
Contact:

Post by lambda »

Code: Select all

echo \`cows\` > /tmp/moo
Watch out for the Manners Taliban!
Isn't it amazing how so many people can type "linuxpakistan.net" into their browsers but not "google.com"?
mudasir
Captain
Posts: 565
Joined: Tue Oct 17, 2006 5:23 am
Location: Dubai
Contact:

Post by mudasir »

AOA,

Dear Mr. Lambda,

Thank you so much, you have solved all my problems...thank you again
Kind Regards
Mudasir Mirza (RHCE)
(+971)55-1045754
http://www.crystalnetworks.org
http://www.diglinux.com
Post Reply