# sh check file size



## graudeejs (Jan 12, 2009)

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 (Jan 12, 2009)

How about du(1)? 


```
$ du -k some-file | awk '{print $1}'
8848
```


----------



## graudeejs (Jan 12, 2009)

dam, why didn't thought about it.
I use this program so many times. lol


----------



## bsddaemon (Jan 13, 2009)

ls without alias would produce the same output:



> % \ls -la 7.0-RELEASE-i386-livefs.iso | awk '{print $5}'
> 224655360


----------



## DutchDaemon (Jan 13, 2009)

'ls -s file' will almost get you there


----------



## graudeejs (Jan 13, 2009)

ye, i know that, i just didn't though it'll be so easy with awk


----------



## dinoex@ (Jan 13, 2009)

*shell using "stat"*

eval $(stat -s "${name}")
echo "size: ${st_size}"


----------



## ephemera (Jan 13, 2009)

dinoex@ said:
			
		

> eval $(stat -s "${name}")
> echo "size: ${st_size}"


Nice.


----------



## Darwin (Jan 18, 2009)

try "Human-readable":

ls -lah somefile | awk '{print $5}'


```
(21:51)-[Darwin@home ~]% ls -lah somefile | awk '{print $5}'
3,2M
```


----------

