Re: get file mode

David T-G <[email protected]>
Newsgroups gmane.comp.gnu.fileutils.bugs
Message-ID <[email protected]>
Arrigo --

...and then Zanette Arrigo said...
% 
% I' ve a simple question.

Hmmm...  That doesn't sound much like a bug report, then.  This list is
really for bug reports for the GNU fileutils package.  However, since
we're here...


% There is a way to get the file mode (octal or text)?

There are lots of ways.  I don't know of a single utility which
specializes in doing that, but the information is easily obtainable
through other simple UNIX tools doing what *they* do best.

You could use ls (hey, I had to stay SOMEWHAT on-topic) with -l and use
cut, awk, sed, or who knows what else to pull out the first field and
then do a little parsing (or maybe something about like '-rwsr-x--x' is
"text" enough for you).

You could use something like perl to stat() the file and report the
answer (if you're writing a perl script).

You could use perl anyway, all in a one-line shell script call (if you're
writing a shell script).

You could write a little C code to do your stat and return the results
however you wish.

I'm sure there are other ways, but my one minute is up.


% I think it would be very useful (I'am writing a script where it would be very 
% useful).

Then just put one of the many tools at your disposal to work :-)  It all
depends on the level of portability you need and how you want to get the
data.


% 
% Thanks,
% 
% Arrigo Zanette


HTH & HAND

:-D
-- 
David T-G                      * There is too much animal courage in 
(play) [email protected] * society and not sufficient moral courage.
(work) [email protected]  -- Mary Baker Eddy, "Science and Health"
http://www.justpickone.org/davidtg/    Shpx gur Pbzzhavpngvbaf Qrprapl Npg!
signature.asc (application/pgp-signature, 187 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)

iD8DBQE94u2pGb7uCXufRwARAmmGAJ9cwJ4gbEGJo4zJakZN5u/CfLnDlACfeU9x
TRI5QnePebNlYrRL9VlW4ig=
=hsl6
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.