Back-Quote in a variable

Discussion of programming on Linux, including shell scripting, perl, python, c/c++, mono, java. Whatever tickles your fancy.

Back-Quote in a variable

Postby mudasir » Sat Apr 12, 2008 11:16 am

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
mudasir
Captain
 
Posts: 565
Joined: Tue Oct 17, 2006 5:23 am
Website: http://www.crystalnetworks.org
Location: Dubai

Postby lambda » Sat Apr 12, 2008 8:53 pm

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"?
lambda
Major General
 
Posts: 3452
Joined: Tue May 27, 2003 7:04 pm
Website: http://www.hungry.com/~fn/
Location: Lahore

Postby mudasir » Sat Apr 12, 2008 8:56 pm

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
mudasir
Captain
 
Posts: 565
Joined: Tue Oct 17, 2006 5:23 am
Website: http://www.crystalnetworks.org
Location: Dubai


Return to “%s” Programming

Who is online

Users browsing this forum: No registered users and 2 guests

cron