The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
column space rollthecoin AIX 4 07-09-2008 09:36 AM
extract column based on name t27 UNIX for Dummies Questions & Answers 3 08-29-2007 02:04 PM
column based search user_007 Shell Programming and Scripting 8 07-01-2007 06:52 AM
filter out certain column from a file CamTu Shell Programming and Scripting 4 04-04-2005 07:24 PM
filter based on column value rraajjiibb Shell Programming and Scripting 2 05-25-2004 10:09 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 10-16-2008
ProGrammar ProGrammar is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 13
intent: df -kh | filter based on capacity (used space) column where % > 85

I want to accomplish this in sh, however if the capability exists only in other shells elsewhere that's acceptable.

% df -kh
Filesystem size used avail capacity Mounted on
...
/dev/dsk/c0t0d0s1 103G 102G 23M 100% /export/DISK15
...
# output truncated for brevity

my objective is to create a script to filter and print all entries in a df -kh output:
- commands available to !/bin/sh - preferred
- where the % value in the capacity column is greater than 85%
- i want the resulting output to print the original entry from df -k output
to contain the filesystem capacity and mount-point

- also I'd like to sort by alphanumeric character contained in the Mounted on column, this is nice to have, not necessary** I didn't have much success with the sort -k 6,6d or 6,6d operands


I'm relatively new to the UNIX environment, windows guy by trade so get the boos and jeers out of your systems up front.

Back to business:

I was thinking foreach statements, not sure how to feed each line to the foreach statement where a carriage return/or new line character would be used as the field separator in foreach input; awk coupled with gt statements but not really sure if that's the best tool. I suspect maybe test statements gotta be used, but I'm drawing blanks as to how to accomplish this and put it together since I have very limited exposure to scripting. I have no idea how to designate carriage returns/new line characters as the field separator for foreach input, remember I'm new I've read documentation for all over so my direction could be severely misguided or even out of correct context.

here are my initial thoughts, this could clarify my intentions

df -kh
either pipe output to input for "foreach command statement" or redirect to temp file, << EOFs (here document) acceptable, probably preferred for conservation of space each time command is run to avoid generating file backlog

either temp file or << EOF provide foreach inputs to be taken for action, at which point I want the % value in the capacity column compared with gt statement against value of 85%.

Then any of the original entries whose capacity column value evaluates as true for the gt 85% comparison, I want those printed and ultimately sorted by alphanumeric value of the mountpoint.

Please let me know if you can help and/or if you want me to do any further footwork, be specific in any following requests so we can get it done right and with minimal delay. Thanks a bunch in advance.

your friendly neighborhood programmar!
 

Bookmarks

Tags
unix commands

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:08 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0