On 04/16/2011 07:47 PM, - - wrote:
here a small bug in stat:
stat -c %n *
stat : option invalide -- 's'
Saisissez « stat --help » pour plus d'informations.
ls
-sdjfè`@$&.txt
stat is not able to list a direstory if a file start with a -
That's not a bug with stat. It's due to the fact that the general unix
style of command parameters starts with a dash. The problem is that for
40 years, the writers of utilities assumed nobody would ever name a file
starting with a dash -- which is why they used a dash to indicate a
command line parameter.
Almost all utilities which use command line parameters or options which
start with a dash will have the same problem with any file that starts
with a dash, because when they see a "-" they think it's a parameter or
option instead of a file.
The solution is to provide a fuller path to the file. Instead of doing
stat * do stat ./* or if the file is named -something, do stat
./-something. The leading "./" (which stands for "Current directory)
comes in front of the dash and so stat doesn't think it's a parameter or
option.
Jesse Gordon