LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   filtering based on columns (http://www.linuxquestions.org/questions/programming-9/filtering-based-on-columns-844006/)

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

Hi,

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 07:32 PM.