Help finding a field value then printing line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help finding a field value then printing line
# 1  
Old 03-08-2011
Help finding a field value then printing line

Hello,
I'm trying to only print out the file systems that are greater than 90% full.
So far I've got:
Code:
df -k >sawky8
cat sawky8 | grep -v Filesystem | sed "s/%//g;" >sawky9
cat sawky9 | awk '{print $4}' | read stot
print $stot
if [ $stot -gt 90 ] ;then
echo $LINE

Problem is it stops after the first line and also doesn't echo it to the tty. Any help much appreciated - I'm still finding my way around KSH!

Cheers

Last edited by Franklin52; 03-09-2011 at 03:58 AM.. Reason: Please use code tags
# 2  
Old 03-08-2011
In my test system disk space usage percentage is displayed on 5th column. So this code works for me:
Code:
df -kP | awk '{x=$5;sub("%","",x);if (x>90){print}}'

Note that I used "-P" df option, to print every filesystem in just one line, so it is much easier to manipulate with AWK.
This User Gave Thanks to bartus11 For This Post:
# 3  
Old 03-08-2011
Shorter Smilie
Code:
df -kP | awk 'int($5)>90'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Printing string from last field of the nth line of file to start (or end) of each line (awk I think)

My file (the output of an experiment) starts off looking like this, _____________________________________________________________ Subjects incorporated to date: 001 Data file started on machine PKSHS260-05CP ********************************************************************** Subject 1,... (9 Replies)
Discussion started by: samonl
9 Replies

2. Shell Programming and Scripting

Command/script to match a field and print the next field of each line in a file.

Hello, I have a text file in the below format: Source Destination State Lag Status CQA02W2K12pl:D:\CAQA ... (10 Replies)
Discussion started by: pocodot
10 Replies

3. Shell Programming and Scripting

Printing uniq first field with the the highest second field

Hi All, I am searching for a script which will produce an output file with the uniq first field with the second field having highest value among all the duplicates.. The output file will produce only the uniqs which are duplicate 3 times.. Input file X 9 B 5 A 1 Z 9 T 4 C 9 A 4... (13 Replies)
Discussion started by: ailnilanjan
13 Replies

4. Shell Programming and Scripting

Compare Field in Current Line with Field in Previous

Hi Guys I have the following file Essentially, I am trying to find the right awk/sed syntax in order to produce the following 3 distinct files from the file above: Basically, I want to print the lines of the file as long as the second field of the current line is equal to the... (9 Replies)
Discussion started by: moutaye
9 Replies

5. Shell Programming and Scripting

printing the max of each field

hi guys im very new to scripting and i have a problem. i need to use awk in my script and the script needs to print the max for each of the columns in a file. for example: numbers.txt 10 15 20 30 40 58 25 30 15 10 38 10 38 8 9 ./max numbers.txt 58 25 38 30 40 i have no clue on how to... (4 Replies)
Discussion started by: youness
4 Replies

6. Shell Programming and Scripting

Help with finding a string and printing value in the next column

Hi, been about 10 years since I've scripted, so very rusty and could use some quick help. I have a file that contains data like such: folder1 jondoe owner janedoe reader joeshmo none folder2 jondoe none janedoe none joeshmo owner folder3 jondoe owner folder4 janedoe owner joeshmo... (7 Replies)
Discussion started by: drewpark
7 Replies

7. UNIX for Dummies Questions & Answers

Help required on printing the line if third field is not a empty space

Hi Experts, I want to print the lines whose third field in non-empty/blank space. i.e. INPUT FILE/B] dcdccghjrry0yd cont dcdccttrk820529 cont rdekedfsSCr dcdccttrdky2d0y cont rdekedfsSC2 ... (3 Replies)
Discussion started by: krao
3 Replies

8. Shell Programming and Scripting

Printing value with no obvious field seperator

Hi all, Can anybody think of a way to do this? I have a file with content like the following: F_TOP_PARAM_VALUEF_TOP_SOURCEF_TOP_DEL_NOTIFICATIONF_DEST_ADDRF_TOP_DEL_TYPE What I want to do is print out the value in the square brackets after F_TOP_SOURCE. So in this case I'd like to print... (4 Replies)
Discussion started by: Donkey25
4 Replies

9. Shell Programming and Scripting

Help with finding length of a field

I have a pipe delimited file. I need to check that the first and second fields are 5 characters long and if not i need to append 0 in front of them to make them 5 characters long. can some body let mwe know how i can find the length of the two fields and then make them 5 characters long if they... (6 Replies)
Discussion started by: dsravan
6 Replies

10. Shell Programming and Scripting

Printing the invert of the last field of awk

in csh set x = "/home/usr/dir1/file1" if i do: echo $x | awk -F\/ '{print $NF}' will result to: "file1" how do i invert the output to: "/home/usr/dir1" :confused: (2 Replies)
Discussion started by: jehrome_rando
2 Replies
Login or Register to Ask a Question