Hello,

I am trying to use the awk command to print two columns. One of them has a percentage value. This is for file system monitoring. When i try to read it from a file it does not recognize the precent sign and ignores it. How can i convert it or skip the % sign when using this command?

Any help would be appreciated.

Thanks.
Shawn

#! /usr/bin/ksh
HOST=`hostname`
cd /home/orabp1/scripts

/usr/bin/df -g | grep -i /bp1db01_bk|awk '{print $7" "$4}' > fs_usage
if [ `cat fs_usage |awk '{print $2}` -gt 36 ]
then
mailx -s "Backup Filesystem Usage in $HOST has exceded" acvd@drede.com < fs_usage
fi


bckp_chk.sh[7]: 35%: 0403-012 A test command parameter is not valid

...
/usr/bin/df -g | grep -i /bp1db01_bk|awk '{sub (/%/, "", $7); print $7" "$4}' > fs_usage
...

Adding a sub() statement to your awk code that deletes the % from the df() output should work. The above syntax should work on your system (AIX & Pains or Solaris?); I'm still using a 1988 version of AT&T's AWK book.

Your code is sub-optimal, but that don't matter because it isn't running 1,000,000 times a second. It'll work.

That worked perfect but now i get this error msg for the next line.
My dumb brain can't figure out how to fix it :(

if [ `cat fs_usage |awk '{print $2}` -gt 36 ]

I tried to change it and put another quotation mark but it didn't solve the issue.

"0403-012 A test command parameter is not vaild."

That worked perfect but now i get this error msg for the next line.
My dumb brain can't figure out how to fix it :(

if [ `cat fs_usage |awk '{print $2}` -gt 36 ]

I tried to change it and put another quotation mark but it didn't solve the issue.

"0403-012 A test command parameter is not vaild."

That's what happens when you've been looking at the problem too long. I'm going through the same thing now on my own project ('updating' Smoothwall Express to use LFS 6.4). Boy am I overlooking stuff that doesn't become obvious very quickly! :( :(

Your awk code is missing the closing apostrophe. And you'll probably find $1 has the numeric value to compare.

That's what happens when you've been looking at the problem too long. I'm going through the same thing now on my own project ('updating' Smoothwall Express to use LFS 6.4). Boy am I overlooking stuff that doesn't become obvious very quickly! :( :(

Your awk code is missing the closing apostrophe. And you'll probably find $1 has the numeric value to compare.

Thanks for your help previously.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.