View Full Version : [Solved] sh check file size
graudeejs
January 13th, 2009, 00:39
How to check single file size with sh?
I'm writing script for burning cds/dvds
I want to check if iso image fits cd/dvd
is there any command for doing something like this?
[i know i can use awk..., (which i also don't know how to use without hours of experiments. lol)]
anomie
January 13th, 2009, 00:41
How about du(1)?
$ du -k some-file | awk '{print $1}'
8848
graudeejs
January 13th, 2009, 00:43
dam, why didn't thought about it.
I use this program so many times. lol
bsddaemon
January 13th, 2009, 04:54
ls without alias would produce the same output:
% \ls -la 7.0-RELEASE-i386-livefs.iso | awk '{print $5}'
224655360
DutchDaemon
January 13th, 2009, 10:31
'ls -s file' will almost get you there ;)
graudeejs
January 13th, 2009, 11:07
ye, i know that, i just didn't though it'll be so easy with awk
dinoex@
January 13th, 2009, 14:04
eval $(stat -s "${name}")
echo "size: ${st_size}"
ephemera
January 13th, 2009, 17:40
eval $(stat -s "${name}")
echo "size: ${st_size}"Nice. ;)
Darwin
January 18th, 2009, 20:01
try "Human-readable":
ls -lah somefile | awk '{print $5}'
(21:51)-[Darwin@home ~]% ls -lah somefile | awk '{print $5}'
3,2M
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.