help with shell programming
hallo i am newbie and i need help
korbin@korbin:~$ df Filesystem 1K-blocks Used Available Use% Mounted on /dev/hda2 2964336 961412 1849912 35% for my shellcode i need to have only the 35% the usage space in per cent ...... thanks :newbie: |
it is not beatiful but works!!
if you need more explanation let me know.. sorry to the shell experts .... i know that looks ugly the code... ; - ) df | grep dev | awk '{print $5}' > out Regards, Slackie |
Code:
df | sed -n 's/.*\([0-9]\)%.*/\1/p' Code:
df | sed -n 's/.*\([0-9]+\)%.*/\1/p' of course, you can add another [0-9] but that will only return if you have a number with 2 digits. slackie: that one will fail if you dont have /dev in your line (for instance, for swap) |
danke
thanks guys :)
|
you are welcome korbin!
ok, h/w ... i wrote the thing only for that case.. 1 drive under /dev/xxx .. for sure if we have other devices listed the "grep" part will fail... Regards |
All times are GMT -5. The time now is 12:51 AM. |