Hallo everyone,
This is my problem below:
/home/cerebrus/pax=>vat class2.sh
ksh: vat: not found
/home/cerebrus/pax=>cat class2.sh
#!/bin/ksh
set -x
bdf|grep appsdev|awk '{ print $5 }'> class3
dd={cat class3}
echo $dd
/home/cerebrus/pax=>
/home/cerebrus/pax=>./class2.sh
+ bdf
+ awk { print $5 }
+ grep appsdev
+ 1> class3
+ class3}
+ dd={cat
./class2.sh[4]: class3}: not found
+ echo
I would like $dd to give me the percentage for /appsdev
Regards,
Paxley
email address removed
vino
July 19, 2006, 8:35am
2
The rules say
(10) Don't post your email address and ask for an email reply. The forums are for the benefit of all, so all Q&A should take place in the forums.
Change this line
dd={cat class3}
to
dd=$(<class3)
Vino, It worked. Thank you very much.
I have another question:
Have a look at my script. What am i doing wrong?
/home/cerebrus/pax=>./class2.sh
+ bdf
+ awk { print $5 }
+ grep appsdev
+ 1> class3
+ dd=59%
+ [ 59% -gt 95% ]
./class2.sh[8]: 59%: more tokens expected
+ echo FILES WONT BE DELETED
FILES WONT BE DELETED
+ echo 59%
59%
/home/cerebrus/pax=>cat class2.sh
#!/bin/ksh
set -x
bdf|grep appsdev|awk '{ print $5 }'> class3
#dd='cat class3'
dd=$(<class3)
#export $dd
#if [ 'grep '$dd' class3|wc -l' -gt 0 ]
if [ $dd -gt 95% ]
then
echo "FILES WILL BE DELETED"
else
echo "FILES WONT BE DELETED"
echo $dd
fi
/home/cerebrus/pax=>
vino
July 20, 2006, 5:24am
5
Get rid of the '%' in the variable dd.
-gt works on numbers. 59% and 95% are not numbers. You need to extract the number out that and then run the script.
Change
dd=$(<class3)
if [ $dd -gt 95% ]
to
dd=$(<class3)
dd=${dd%\%}
if [ $dd -gt 95 ]
Not tested tho'.
Its not working:
/home/cerebrus/pax=>./class2.sh
+ bdf
+ awk { print $5 }
+ grep appsdev
+ 1> class3
+ dd=
+ [ -gt 95 ]
./class2.sh[8]: test: argument expected
+ echo FILES WONT BE DELETED
FILES WONT BE DELETED
+ echo
/home/cerebrus/pax=>
This is how the code looks like:
/home/cerebrus/pax=>cat class2.sh
#!/bin/ksh
set -x
bdf|grep appsdev|awk '{ print $5 }'> class3
dd=${dd%\%} #'cat class3'
##dd=$(<class3)
#export $dd
#if [ 'grep '$dd' class3|wc -l' -gt 0 ]
if [ $dd -gt 95 ]
then
echo "FILES WILL BE DELETED"
else
echo "FILES WONT BE DELETED"
echo $dd
fi
/home/cerebrus/pax=>
vino
July 20, 2006, 5:49am
8
dd=$(<class3)
if [ $dd -gt 95% ]
should be
dd=$(<class3)
dd=${dd%\%}
if [ $dd -gt 95 ]
Thnx Vino, i bow down to you.