Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

How would I loop this line to print everything jpg to a text file??

stat --printf="%s" *.jpg >> results.txt

How would you also be able to print results.txt based on a file size?? How would the code look?? The exact size of the file is 40318

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
166 views
Welcome To Ask or Share your Answers For Others

1 Answer

You already are printing the results for all *.jpg files. The only problem is that by using --printf="%s" you are changing the output format of stat to print only the size (without line breaks or spaces in between each item).

Try instead:

stat --printf="%s
" *.jpg >> results.txt
#  OR
stat -c "%s" *.jpg >> results.txt

To print the filename next to the size, try:

stat --printf="%n %s
" *.jpg >> results.txt
# OR
stat -c "%n %s" *.jpg >> results.txt

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...