File name beginning with - (dash)
Use ./
before filename:
for i in *; do stat -c "%s %n" "./$i"; done
Or use --
to indicate the end of options for stat
:
for i in *; do stat -c "%s %n" -- "$i"; done
Though that one will still fail for a file called -
(will report information for the file open on stdin instead of the -
file in the current directory).
Add --
to mark the end of the options to stat
:
for i in *; do stat -c "%s %n" -- "$i"; done