command, and related commands like
give lots of information about a file (more exactly, about a file's
The information is printed in a way that's (sort of) nice to look at.
But the format might not be exactly what you want.
That format can be tough for shell programmers to use:
parsing the output with
, and others is tricky
and a pain (article
has an example).
output is different on BSD and System V systems.
command solves those problems and more.
It lets you:
Make your own output format: pick the information you want to see
and the order it's shown.
Sort the output on one or more fields.
Make a consistent date format: numeric or in words, include the seconds
if you want to, and more.
Best of all, the date format won't change for files more than six months old
(unless you use the
And there's much more.
The manual page on the disc explains
formatting in detail.
Here are a few examples.
Let's start with the style of
output that has
fixed-width columns and doesn't show group ownership.
is similar, but its
date format doesn't change after six months and it doesn't have the
-rw-r----- 1 jerry 1641 Feb 29 1992 afile
lrwxrwxrwx 1 jerry 8 Nov 18 00:38 bfile -> ../bfile
Here's a more user-friendly format for people who aren't UNIX hackers
(it might be best to put this into an
alias or shell function (
The date and time are shown, followed by the owner's name, the size in
kbytes, and the filename without the symbolic link information like
sls -p '%m"%F %d, 19%y %r" %u %4skK %n'
February 29, 1992 03:43:00 PM jerry 2K afile
November 18, 1992 00:38:22 AM jerry 1K bfile
How about a simple
output that shows all three
file dates (
modification, access, and inode change?
to print a title first:
echo 'modify access inode'; \
sls -p '%m"%D" %a"%D" %c"%D" %n'
modify access inode
02/29/92 09/17/92 11/18/92 afile
11/18/92 11/18/92 11/18/92 bfile
Finally, let's ask
to make a set of UNIX commands that could be
used at the end of a
shell archive (
These commands would recreate the modes, date and owner (with a numeric UID)
as the files are extracted from the archive:
sls -p 'chmod %P %n; chown %U %n; touch %m"%m%d%H%M%y" %n'
chmod 640 afile; chown 225 afile; touch 0229154392 afile
chmod 777 bfile; chown 225 bfile; touch 1118003892 bfile
I didn't show the sorting options or many of the other output format
But I hope I've given you an idea (or ten).