LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-13-2010, 02:45 AM   #1
AlbertJJ
LQ Newbie
 
Registered: Oct 2010
Posts: 12

Rep: Reputation: 0
Question 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
 
Old 11-13-2010, 02:58 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Hi,

Is this what you are looking for?

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

Hope this helps.
 
1 members found this post helpful.
Old 11-13-2010, 03:58 AM   #3
AlbertJJ
LQ Newbie
 
Registered: Oct 2010
Posts: 12

Original Poster
Rep: Reputation: 0
Thanks a lost Druuna!! Cheers!!
 
Old 11-13-2010, 04:03 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
You're welcome
 
  


Reply

Tags
command, filtering


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux based filtering tap for IDS aarondcounts Linux - Security 4 12-16-2009 01:37 PM
Syslog Content Based Filtering emmitt1219 Linux - Newbie 5 07-11-2009 07:06 PM
User based ip filtering? Balakrishnan84 Linux - Security 12 08-06-2007 02:53 AM
String based filtering jacobm Linux - Security 2 01-07-2006 07:48 AM
Sendmail Spam filtering and Virus filtering MrJoshua Linux - General 2 04-03-2003 11:12 AM


All times are GMT -5. The time now is 02:27 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration