LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 09-26-2008, 04:23 AM   #1
ZAMO
Member
 
Registered: Mar 2007
Distribution: Redhat &CentOS
Posts: 579

Rep: Reputation: 30
To list the file on MB size only


Is there anyway to list the files on size of Megabytes only?
Am using ls -lh always or sometimes du -sh/ch,but they can list them in kb.

Say if a files is 724Kbytes, is there any way to print it in MB?

Thanks
 
Old 09-26-2008, 04:59 AM   #2
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Here's a hack; it's not nice, and it doesn't handle files with spaces in it, but you get the idea:
Code:
ls -l | awk '{printf "%s %i %s %s %.3fMB %s %i %s %s\n", $1,$2,$3,$4,$5/1024000,$6,$7,$8,$9}'

Last edited by pwc101; 09-26-2008 at 05:00 AM.
 
Old 09-26-2008, 05:37 AM   #3
ZAMO
Member
 
Registered: Mar 2007
Distribution: Redhat &CentOS
Posts: 579

Original Poster
Rep: Reputation: 30
Thanks PWc101 .... It's Great
 
Old 10-04-2008, 07:05 AM   #4
timnp
Member
 
Registered: Feb 2008
Location: London
Distribution: FC8, FC9, Centos 4, Centos 5, Knoppix
Posts: 52

Rep: Reputation: 16
It always rounds up so it isn't very accurate for small files but you could try

Code:
ls -l --block-size=1M
 
Old 10-04-2008, 09:21 AM   #5
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
Quote:
Originally Posted by ZAMO View Post
Is there anyway to list the files on size of Megabytes only?
Code:
du -sh *|egrep '^[0-9]+(,[0-9]+)*M.*$'
or if (for some reason) your locale uses "." instead of "," to separate numbers, then:
Code:
du -sh *|egrep '^[0-9]+(\.[0-9]+)*M.*$'

Last edited by ErV; 10-04-2008 at 09:44 AM.
 
  


Reply


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
List LS query by file size hammertime1983 Linux - Newbie 3 05-27-2013 02:38 AM
any ideas to reduce log file size or make log file size managed? George2 Programming 2 08-13-2006 06:55 AM
file system size larger than fysical size:superblock or partition table corrupt klizon Linux - General 0 06-18-2004 04:18 PM
How to list total file size of a directory phil1076 Linux - General 3 12-18-2003 03:47 PM
list size of directory and all directories it contains? ubien Linux - General 2 01-11-2003 10:59 AM


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

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