The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Simple C question... Hopefully it's simple Xeed High Level Programming 6 12-15-2006 02:29 PM
Very simple question roger19 UNIX for Dummies Questions & Answers 4 07-17-2006 08:36 PM
Ok simple question for simple knowledge... Corrail UNIX for Dummies Questions & Answers 1 11-28-2005 01:03 PM
a simple question pnxi UNIX for Advanced & Expert Users 2 11-12-2003 02:10 AM
a very simple question (but i don't know) dell9 High Level Programming 1 10-30-2001 03:37 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-05-2008
bbbngowc bbbngowc is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 196
Simple fle size question

I'm sure this is a simple one, but I'm new to UNIX and I can't figure it out.

How do I view file size in Megabytes? I have files in a directory and the size is 184710. I think this is in bytes but I'm not usre. How can I view this in MB.

Thanks.
  #2 (permalink)  
Old 02-05-2008
sysgate's Avatar
sysgate sysgate is offline Forum Advisor  
Unix based
  
 

Join Date: Nov 2006
Location: Bulgaria
Posts: 1,323
for single file : "ls -lh file-name" , for directory - "du -sch /folder-name" # that's the total folder size.
That's on most GNU distros, what is your OS ?
  #3 (permalink)  
Old 02-05-2008
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2005
Location: Switzerland - GE
Posts: 1,585
man du (the arguments depend of OS... but what works on all is du -sk <filename> and result is in KB...)
  #4 (permalink)  
Old 02-05-2008
gus2000 gus2000 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 157

Code:
# FILE=mybigfile.txt

# ls -l $FILE
-rw-r--r--  1 root    staff     14639794 Aug 22 2006  mybigfile.txt

# awk 'BEGIN{"ls -l " "'$FILE'"|getline;printf "%s %5.2fMiB\n",$NF,$5/2^20}'
mybigfile.txt 13.96MiB

# awk 'BEGIN{"ls -l " "'$FILE'"|getline;printf "%s %5.2fMB\n",$NF,$5/10^6}'
mybigfile.txt 14.64MB

The above should work for any distro, provided that "ls" puts the filesize in column 5.

See Megabyte - Wikipedia for the differences between megabyte (MB) and mebibyte (MiB).
  #5 (permalink)  
Old 02-05-2008
OuterVillage.co OuterVillage.co is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 3
Quote:
Originally Posted by bbbngowc View Post
I'm sure this is a simple one, but I'm new to UNIX and I can't figure it out.

How do I view file size in Megabytes? I have files in a directory and the size is 184710. I think this is in bytes but I'm not usre. How can I view this in MB.

Thanks.
Depending on the OS you can use the -h option.
For example: ls -lh or du -sh *
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:47 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0