LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-06-2004, 02:39 PM   #1
korbin
LQ Newbie
 
Registered: Jan 2004
Posts: 9

Rep: Reputation: 0
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
 
Old 01-06-2004, 02:50 PM   #2
slackie1000
Senior Member
 
Registered: Dec 2003
Location: Brasil
Distribution: Arch
Posts: 1,037

Rep: Reputation: 46
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
 
Old 01-06-2004, 03:16 PM   #3
h/w
Senior Member
 
Registered: Mar 2003
Location: New York, NY
Distribution: Debian Testing
Posts: 1,286

Rep: Reputation: 46
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)

Last edited by h/w; 01-06-2004 at 03:19 PM.
 
Old 01-06-2004, 03:23 PM   #4
korbin
LQ Newbie
 
Registered: Jan 2004
Posts: 9

Original Poster
Rep: Reputation: 0
danke

thanks guys
 
Old 01-07-2004, 03:20 AM   #5
slackie1000
Senior Member
 
Registered: Dec 2003
Location: Brasil
Distribution: Arch
Posts: 1,037

Rep: Reputation: 46
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell programming quan Programming 8 11-27-2005 07:46 PM
shell programming qerf Linux - Newbie 5 11-06-2005 05:28 PM
programming shell tuls Slackware 3 08-24-2005 05:58 PM
new to shell programming bluetwist Debian 3 08-01-2005 03:56 PM
Shell Programming eantoranz Linux - Networking 2 06-02-2005 11:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration