File size using BASH script
How can I get the size of a file using bash scrpt? thanks.
|
Code:
#!/bin/bash |
thanks very much
|
Hi cb.....,
U can use DF command. Please use manual man df ,info df for more. |
dummy one,
Code:
ls -l filename |awk -F" "'{ print $5 }' |
try:
du file du -h file du -k file |
Get File Size In Bash Script Using DU and SED
Another option:
Code:
X=~/The_File |
cat <filename> | wc -c
jlinkels |
another way to skin the cat
ls -l $FILENAME | cut -d " " -f 6 |
'ls' is NOT reliable for telling file sizes. Use 'stat' it is most reliable.
|
Can you please explain why these other methods are not reliable?
|
Not all programs determine the file size in the same way. Some methods simply don't give an accurate result.
|
Quote:
|
Quote:
Code:
stat --printf="%s" file.any |
Ooh! Yes, using stat is much better than what I came up with. Thank you!
|
Is there explanation too?
|
Quote:
|
All times are GMT -5. The time now is 07:12 AM. |