Operating System - HP-UX
1833680 Members
4935 Online
110062 Solutions
New Discussion

show all files with highliten one

 
SOLVED
Go to solution
Jeeshan
Honored Contributor

show all files with highliten one

I have a file which has a formatted output of bdf output. I need to view all the contents of file including the threshold limit color.But only the threshold limit line is coming. I nned the full content including the threshold colored line

cat $edTmp |
while read line
do
err=`echo $line | awk '{print $5}'`
if [[ $err>"70%" && $err <="90%" ]]
then
echo "\033[0;31m$line \033[0;39m"
fi
done

Note: edTmp is a formatted output of bdf command.
a warrior never quits
5 REPLIES 5
Suraj K Sankari
Honored Contributor

Re: show all files with highliten one

Hi,

Please download this file (bdfmesg) from below link you will find this is a great tool written by Mr.Bill Hassell.

http://forums13.itrc.hp.com/service/forums/questionanswer.do?threadId=1326767

Just give

#bdfmesg -P 80 ##to find all file system which is using 80 or more then 80

Like so many output you can take from bdfmesg

Many Thanks to Mr.Bill Hassell to create a nice and useful tool.

Suraj
Jeeshan
Honored Contributor

Re: show all files with highliten one

Hi Suraj

I have this script and no doubt its a good tool. But i need my exact solution to get rid of the scripting problem.
a warrior never quits
Matti_Kurkela
Honored Contributor
Solution

Re: show all files with highliten one

Your script tests whether the %used value on each line is between 70% and 90%. If it is, then the line is displayed with color codes added. If it isn't, nothing at all is displayed.

To display the other lines too, the if...then...fi condition in the script needs an "else" clause. In other words, the logic within the loop should be:
IF [value between 70% and 90%]
THEN echo the line with color codes
ELSE echo the line without color codes
FI

MK
MK
James R. Ferguson
Acclaimed Contributor

Re: show all files with highliten one

Hi:

To add to Matti's directions, in order to retain the formating (spacing) you have in the colored lines, be sure to do your 'echo' of the non-colored ones in double quotes, too:

if [[ $err>"70%" && $err <="90%" ]]; then
echo "\033[0;31m${line }\033[0;39m"
else
echo "${line}"
fi

...That said, you can also eliminate the extra 'cat' process:

while read line
do
err=`echo $line | awk '{print $5}'`
if [[ $err>"40%" && $err <="90%" ]]; then
echo "\033[0;31m${line} \033[0;39m"
else
echo "${line}"
fi
done < ${edTmp}

...

Regards!

...JRF...
Jeeshan
Honored Contributor

Re: show all files with highliten one

works fine
a warrior never quits