Getting size of a file
Hi
I want to write a script that finds the size of some of the files in a specific directory. Is there any command that returns the size of a file?? thanx rYr |
Code:
stat -c %s filename |
thanx ..
On Redhat Linux WS 2.1 there is no -c option. In the remaining options i didnt find anything that gives the size of a file. On AIX machine there is no stat command available. Is there some other command available that i can use in my shell script?? |
I think you need to quote "%s" like that.
I think you need to quote "%s"
stat -c "%s" awake.mp3 5158034 :study: read stat --help this is stat on redhat 9.1 also du (Disk Usage) command du -b awake.mp3 5173248 awake.mp3 once you know what the commands are called you can read the manpages/ infopages on them :) info -n "Top" "coreutils.info" "Disk usage" covers du and stat and sf and sync for me. If you're writing scripts then you might be reading the info/man pages lots! which stat /usr/bin/stat stat --version stat (coreutils) 4.5.3 Written by Michael Meskes. stat awake.mp3 File: `awake.mp3' Size: 5158034 Blocks: 10104 IO Block: 4096 Regular File Device: 302h/770d Inode: 1771899 Links: 1 Access: (0664/-rw-rw-r--) Uid: ( 500/ jamesc) Gid: ( 500/ jamesc) Access: 2004-12-14 13:05:17.000000000 +0000 Modify: 2004-12-14 13:02:21.000000000 +0000 Change: 2004-12-14 13:02:21.000000000 +0000 |
thanx this info was helpful..
I did have a problem though that "du -b" option was not available in AIX so it works fine on Linux but fails on AIX. Now i am using a combination of "ls -l" and "awk" to get the size. ls -l myfile.txt |awk '// {print $5}' it works fine both in linux and AIX :) |
All times are GMT -5. The time now is 02:54 PM. |