[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#8513: stat list file name

From: Jesse Gordon
Subject: bug#8513: stat list file name
Date: Sat, 16 Apr 2011 23:01:49 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20101125 Thunderbird/3.0.11

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.


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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]