How to sort df -h out put :


 
Thread Tools Search this Thread
Operating Systems Solaris How to sort df -h out put :
# 1  
Old 03-10-2012
How to sort df -h out put :

Hello every one ,

I am just trying to sort df -h out in a particular order to differentiate SAN disks and local disks .. does any body have any script or any useful command ??
thanks in advance ..
# 2  
Old 03-10-2012
Code:
 df -h | sort

is a starting point.

Please show us what df -h gives for input to sort and your expected output.
Device and other things are not really universal in Solaris, so I'm not clear what your problem is. Normally the output of df is pretty much usable as is.
This User Gave Thanks to jim mcnamara For This Post:
# 3  
Old 03-11-2012
Thanks Jim for ur time and for ur response ... here is my df -h out put
Code:
mdsuaor18:> df -h
Filesystem             size   used  avail capacity  Mounted on
/dev/md/dsk/d1         4.9G   3.4G   1.5G    70%    /
/devices                 0K     0K     0K     0%    /devices
ctfs                     0K     0K     0K     0%    /system/contract
proc                     0K     0K     0K     0%    /proc
mnttab                   0K     0K     0K     0%    /etc/mnttab
swap                    52G   1.1M    52G     1%    /etc/svc/volatile
objfs                    0K     0K     0K     0%    /system/object
/platform/sun4u-us3/lib/libc_psr/libc_psr_hwcap2.so.1
                       4.9G   3.4G   1.5G    70%    /platform/sun4u-us3/lib/libc_psr.so.1
/platform/sun4u-us3/lib/sparcv9/libc_psr/libc_psr_hwcap2.so.1
                       4.9G   3.4G   1.5G    70%    /platform/sun4u-us3/lib/sparcv9/libc_psr.so.1
fd                       0K     0K     0K     0%    /dev/fd
/dev/md/dsk/d4         2.0G   1.1G   871M    56%    /var
swap                    52G   5.6M    52G     1%    /tmp
swap                    52G    32K    52G     1%    /var/run
/dev/md/dsk/d170        39G    18G    21G    45%    /d02
/dev/md/dsk/d180       315G   175G   139G    56%    /d01
/dev/md/dsk/d5         2.0G   415M   1.5G    22%    /opt
/dev/md/dsk/d160        99G   3.5G    95G     4%    /archive
/dev/md/dsk/d190       606G   330G   271G    55%    /d03
/dev/md/dsk/d100        93M    70M    14M    84%    /home
/dev/md/dsk/d150        98G    12G    85G    13%    /orabackup
mdsuaor18:>

i am trying to sort this out put based on mount points in the following order
Code:
/d01 
/d02
/d03
/archive 
/orabackup

any suggestions ? ty ...

Last edited by methyl; 03-11-2012 at 04:38 PM.. Reason: code tags on example
# 4  
Old 03-11-2012
Hi new2uniks,

What kind of sort is that?

Shouldn't be /archive ordered before than /d01? I can't see the point.
# 5  
Old 03-11-2012
Try the following;

Code:
df -h | grep -v Mounted | sort -k 6,6

Based on the assumption that you actually do want sorted outputSmilie
This User Gave Thanks to gull04 For This Post:
# 6  
Old 03-11-2012
i am little Smilie by ur qn .. i dnt mind about /archive and /orabackup order ... they may come first or last .. but the rest should be in order like d01 d02 d03 ...
# 7  
Old 03-11-2012
Sorry about that should have included a separator in the command as follows;

Code:
df -h | grep -v Mounted | sort -t"        " -k 6,6

After the first set of quote marks you need to hold down the ctrl key and press lowercase v and then uppercase I before closing the quotes this will give you a tab separator in the command. I don't have access to my Sun box just now so cant test - sorry.

Regards

Dave

Last edited by gull04; 03-11-2012 at 03:02 PM.. Reason: Incomplete
This User Gave Thanks to gull04 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Use sort to sort numerical column

How to sort the following output based on lowest to highest BE? The following sort does not work. $ sort -t. -k1,1n -k2,2n bfd.txt BE31.116 0s 0s DOWN DAMP BE31.116 0s 0s DOWN DAMP BE31.117 0s 0s ... (7 Replies)
Discussion started by: sand1234
7 Replies

2. UNIX for Beginners Questions & Answers

Difference of Sort -n -k2 -k3 & Sort -n -k2,3

Hi, Could anyone kindly show me a link or explain the difference between sort -n -k2 -k3 & sort -n -k2,3 Also, if I like to remove the row with repetition at both $2 and $3, Can I safely use sort -u -k2 -k3 Example; 100 20 30 100 20 30 So, both $2 and $3 are same and I... (2 Replies)
Discussion started by: Indra2011
2 Replies

3. Shell Programming and Scripting

Sort help: How to sort collected 'file list' by date stamp :

Hi Experts, I have a filelist collected from another server , now want to sort the output using date/time stamp filed. - Filed 6, 7,8 are showing the date/time/stamp. Here is the input: #---------------------------------------------------------------------- -rw------- 1 root ... (3 Replies)
Discussion started by: rveri
3 Replies

4. Shell Programming and Scripting

Help with sort word and general numeric sort at the same time

Input file: 100%ABC2 3.44E-12 USA A2M%H02579 0E0 UK 100%ABC2 5.34E-8 UK 100%ABC2 3.25E-12 USA A2M%H02579 5E-45 UK Output file: 100%ABC2 3.44E-12 USA 100%ABC2 3.25E-12 USA 100%ABC2 5.34E-8 UK A2M%H02579 0E0 UK A2M%H02579 5E-45 UK Code try: sort -k1,1 -g -k2 -r input.txt... (2 Replies)
Discussion started by: perl_beginner
2 Replies

5. Shell Programming and Scripting

Alternate to sort --random-sort

sort --random-sort The full command is path=`find /testdir -maxdepth 1 -mindepth 1 -type d | ***Some sort of sort function*** | head -1` I have a list I want to randomly sort. It works fine in ubuntu but on a 'osx lion' sort dosen't have the --random-sort option. I don't want to... (5 Replies)
Discussion started by: digitalviking
5 Replies

6. Shell Programming and Scripting

Is it Possible to sort a list of hexadecimal numbers using "sort" command?

Hello Everybody :) !!!. i have question in mind, is it possible to sort a list of hexadecimal numbers using "sort" command? (9 Replies)
Discussion started by: Kesavan
9 Replies

7. UNIX for Advanced & Expert Users

Script to sort the files and append the extension .sort to the sorted version of the file

Hello all - I am to this forum and fairly new in learning unix and finding some difficulty in preparing a small shell script. I am trying to make script to sort all the files given by user as input (either the exact full name of the file or say the files matching the criteria like all files... (3 Replies)
Discussion started by: pankaj80
3 Replies

8. Shell Programming and Scripting

How to Sort Floating Numbers Using the Sort Command?

Hi to all. I'm trying to sort this with the Unix command sort. user1:12345678:3.5:2.5:8:1:2:3 user2:12345679:4.5:3.5:8:1:3:2 user3:12345687:5.5:2.5:6:1:3:2 user4:12345670:5.5:2.5:5:3:2:1 user5:12345671:2.5:5.5:7:2:3:1 I need to get this: user3:12345687:5.5:2.5:6:1:3:2... (7 Replies)
Discussion started by: daniel.gbaena
7 Replies

9. Shell Programming and Scripting

awk -- sort out the out put file

Hi, using awk /sed, I need to sort out the input file. here is the example input file=== Name= shashi | country= india | region = asia | dept= ww Name= jon | region = asia | dept= xx Name=sam | dept= ww Name= anthony | country=england | dept= xx Name= sumo | country= china output... (3 Replies)
Discussion started by: hegdeshashi
3 Replies

10. Shell Programming and Scripting

Perl find::file can I sort the out put

Perl file::find can I sort the out put I am using file::find in my script but how I wish to process each file found in date order. Can I sort this module? eg part of current script is.... use File::Find; # Recursively find all files and directories in $mqueue_directory find(\&wanted,... (2 Replies)
Discussion started by: Andrek
2 Replies
Login or Register to Ask a Question