LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   help with shell programming (https://www.linuxquestions.org/questions/linux-newbie-8/help-with-shell-programming-132129/)

korbin 01-06-2004 02:39 PM

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:

slackie1000 01-06-2004 02:50 PM

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

h/w 01-06-2004 03:16 PM

Code:

df | sed -n 's/.*\([0-9]\)%.*/\1/p'
i've been trying that. it will get you the last digit, but not the one in tens place. i dont know why a
Code:

df | sed -n 's/.*\([0-9]+\)%.*/\1/p'
doesnt work.

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)

korbin 01-06-2004 03:23 PM

danke
 
thanks guys :)

slackie1000 01-07-2004 03:20 AM

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.