Results 1 to 3 of 3
Hi guys,
I was wondering if someone can help me.
I have written a two line bash script, which is shown below:
df_out=$(command df)
echo $df_out | awk '{print $42}'
...
- 12-11-2008 #1Linux User
- Join Date
- Jul 2007
- Location
- Greece
- Posts
- 277
Is my output an integer?
Hi guys,
I was wondering if someone can help me.
I have written a two line bash script, which is shown below:
df_out=$(command df)
echo $df_out | awk '{print $42}'
The output of this command is 92%, and basically shows the disk usage. (I am trying to write a script which is going to alert me everytime the disk's capacity is over 95%.)
The next step is to write an if statement but before I do, can you please tell whether the output 92% is considered as an integer or not? Is the % sign that worries me. Can I go ahead and write the if statement using the number as it is?
Please ask if I haven't made myself clear.
Thanks a lot.
- 12-11-2008 #2Linux User
- Join Date
- Jun 2007
- Posts
- 318
No, 92% isn't an integer because of the percent sign. You have to remove it.
Code:df_out=$(command df) nmbr=$(echo $df_out | awk '{print $42}') nmbr=${nmbr/\%/} if [ $nmbr -gt 95 ]; then echo "over"; fi
- 12-11-2008 #3Linux User
- Join Date
- Jul 2007
- Location
- Greece
- Posts
- 277
Thanks a lot for your answer vsemaska
It works perfectly


Reply With Quote