Finding a file size
Hello, newbie here;
Scenario: Need to find the size of a file (html), and display it in a summary file. Any suggestions? (Have tried du, ls, size, but none of these work) Thanks, LneWlf |
Not obvious why not just something like:
Code:
$ ls -lh filename.html > summaryFile.txt |
Hi and welcome to LinuxQuestions!
Have you tried stat? By the way, what do you mean by "none of these work"? All the cited command can be used to retrieve different information from file objects, ls being the most suitable to retrieve the size of a file (unless you have to deal with sparse files). In any case, I believe stat is exactly what you're looking for. |
not obvious why use ls (o_0) instead of stat:
Code:
stat -c %s file.html > size.txt |
Oh dear.:)
|
Quote:
Code:
ls -l|awk 'NR>1{print $5}' |
As ghostdog mentioned, even find should work and you can take advantages of the searching criteria, e.g.
Code:
find . -name \*.html -printf "%f size is %s bytes\n" |
All times are GMT -5. The time now is 05:07 PM. |