-   Programming (
-   -   filtering based on columns (

AlbertJJ 11-13-2010 01:45 AM

filtering based on columns
Is there any way to filter the output of a command based on the values on the output columns. For example i execute du -h on directory with many files. Now I want to filter the output based on the size (i.e. M or G or K ). The filtered o/p should contain only M(megabytes) or G(gigabytes) and also all columns.

20K ./fload/temp/20000101/Pam
15K ./fload/temp/20000101/NAVEX
29K ./fload/temp/20000101/Avenge
64K ./fload/temp/20000101
20K ./fload/temp/20000229/Pam
15K ./fload/temp/20000229/NAVEX
29K ./fload/temp/20000229/Avenge
64K ./fload/temp/20000229

druuna 11-13-2010 01:58 AM


Is this what you are looking for?

du -h | grep "^.*[MG][[:space:]]\./"

Hope this helps.

AlbertJJ 11-13-2010 02:58 AM

Thanks a lost Druuna!! Cheers!! :)

druuna 11-13-2010 03:03 AM

You're welcome :)

All times are GMT -5. The time now is 11:57 PM.