Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Any awk one liner to print df output? Post 302801993 by newbie_01 on Thursday 2nd of May 2013 06:34:27 PM
Old 05-02-2013
Any awk one liner to print df output?

Hi,

OS = Solaris

Can anyone advise if there is a one liner to print specific output from a df -k output?

Running df from a command line, it sometimes gives me 2 lines for some volume. By re-directing the output to a file, it always gives 1 line for each.

Below is an example output, I've modified some of the volume names for confidential reason.

Code:
Filesystem            kbytes    used   avail capacity  Mounted on
server01:/vol/vol_01/01 319815680 246331968 73483712    78%    /nas_mnt/server01/vol_01/01
server01:/vol/vol_02/02 284164096 255495160 28668936    90%    /nas_mnt/server01/vol_02/02
server01:/vol/vol_03/03 8388608 7686776  701832    92%    /nas_mnt/server01/vol_03/03
server01:/vol/vol_04/04 12066816 6133128 5933688    51%    /nas_mnt/server01/vol_04/04
server01:/vol/vol_05/05 752877568 394102812 358774756    53%    /nas_mnt/server01/vol_05/05
server01:/vol/vol_06/06 3145728 2591832  553896    83%    /nas_mnt/server01/vol_06/06
server01:/vol/vol_07/07 6266880 5037936 1228944    81%    /nas_mnt/server01/vol_07/07

Can anyone advise if there is any way to print the lines matching where the capacity is >= 80%?

How do I change the one-liner below to print the whole line?

Code:
 
awk '{ print $5 }' /tmp/df.out | awk -F% '$1 >= 80 { print $1 }'

Ideally, I would want to convert the kbytes, used and avail to GB as well but the first one will give errors as it is the df header.

FYI, I am using df -k because some of my Solaris servers do not have the df -h so I need a df -k output but I want to convert them to GB via awk.

Any advice much appreciated. Thanks in advance.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute the output of one liner print

Hello I wrote simple one liner that take RunTime *.exe and link them to the output of the compilation output: find ~/DevEnv/. -name "*.exe" | xargs ls -l | awk '{ x=split($9,a,"/"); print "ln -s " $9 " "a}' and it gives me the desire output , but how can I execute this ln command on every... (1 Reply)
Discussion started by: umen
1 Replies

2. Shell Programming and Scripting

using awk to search and print output

suppose i have one file file A 18 24 30 35 38 45 55 Another file file B 08_46 A 16 V -0.36 0.23 E : 1.41 08_46 A 17 D -1.04 0.22 E : 0.84 08_46 A 18 Q -0.49 0.12 E : 0.06 08_46 A 19 G 0.50 0.14 E : 0.05 08_46 A 20 V ... (5 Replies)
Discussion started by: cdfd123
5 Replies

3. Shell Programming and Scripting

using perl or awk to print output

suppose u have file File A A -> G C->D A -> R P->A File B A=1 C=2 D=3 E=4 F=5 G=6 H=7 I=8 K=9 L=10 M=11 (5 Replies)
Discussion started by: cdfd123
5 Replies

4. UNIX for Dummies Questions & Answers

awk {print $NF} output??

Hi, I am trying to debug an old script and have found the problem lies within this function: isIdoc() { # validate the file type fileType=`file $1 | awk '{print $NF}'` && echo 0 || echo 1 } My question is, how can I determine what is in the variable $fileType ? The program is... (1 Reply)
Discussion started by: vervette
1 Replies

5. Shell Programming and Scripting

awk: Multiple search patterns & print in an one liner

I would like to print result of multiple search pattern invoked from an one liner. The code looks like this but won't work gawk -F '{{if ($0 ~ /pattern1/) pat1=$1 && if ($0 ~ /pattern2/) pat2=$2} ; print pat1, pat2}' Can anybody help getting the right code? (10 Replies)
Discussion started by: sdf
10 Replies

6. Shell Programming and Scripting

Search & Replace regex Perl one liner to AWK one liner

Thanks for giving your time and effort to answer questions and helping newbies like me understand awk. I have a huge file, millions of lines, so perl takes quite a bit of time, I'd like to convert these perl one liners to awk. Basically I'd like all lines with ISA sandwiched between... (9 Replies)
Discussion started by: verge
9 Replies

7. Shell Programming and Scripting

Awk script to run a sql and print the output to an output file

Hi All, I have around 900 Select Sql's which I would like to run in an awk script and print the output of those sql's in an txt file. Can you anyone pls let me know how do I do it and execute the awk script? Thanks. (4 Replies)
Discussion started by: adept
4 Replies

8. Shell Programming and Scripting

awk one liner to print to end of line

Given: 1,2,whatever,a,940,sot how can i print from one particular field to the end of line? awk -F"," '{print $2 - endofline}' the delimiter just happens to be a comma "," in this case. in other cases, it could be hypens: 1---2---whatever---a---940---sot (4 Replies)
Discussion started by: SkySmart
4 Replies

9. Shell Programming and Scripting

Looking to improve the output of this awk one-liner

I have the following awk one-liner I came up with last night to gather some data. and it works pretty well (apologies, I'm quite new with awk, and don't know how to format this pretty-printed). You can see the output with it. awk '{if ($8 == 41015 && $21 == "requests") arr+=$20;if ($8 == 41015... (3 Replies)
Discussion started by: DeCoTwc
3 Replies

10. Shell Programming and Scripting

awk print output problem

Hello friends, I have written a script and i need to add some part into it so that i could print out more results depending on more conditions, This is the core part of the script which does the actual work: echo "$j" && nawk -v stat=$2 'NR==FNR &&... (1 Reply)
Discussion started by: EAGL€
1 Replies
GPIV_ROT180(1)						      General Commands Manual						    GPIV_ROT180(1)

NAME
gpiv_rot180 - Simple data manipulation tool for PIV data. SYNOPSIS
gpiv_rot180 [-h | --help] [-p | --print] [-p | --version] [filename] < stdin > stdout DESCRIPTION
gpiv_rot180 rotates the data over 180 degrees. As rotating over 180 degrees is identic to flipping over x as well as over y-direction, flipx and flipy may be used instead of gpiv_rot180. The parameters read from the configuration resources (containing the key POST) may be overruled by the command line options, as explained below. Options -h | --help On-line help. -p | --print Prints parameters, command line options and input and output filenames to stdout. The output may be used as parameters of gpiv_rot180 for future use by re-directing stdout to gpiv_rot180.par. -v | --version Print version information on standard output, then exits successfully. filename Input PIV file. Overrides stdin and stdout. Output will be written to filename.ma.piv. The parameters will be written or appended to filename.par. SEE ALSO
manipiv, flipx, flipy, gpivtools AUTHOR
Gerber Van der Graaf 8 November 2006 GPIV_ROT180(1)
All times are GMT -4. The time now is 07:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy