Bash shell questions

So I'm in an OS class right now. First lab is pretty much fiddle around with the Bash shell. Anyway, the professor has an example of displaying a directory in reverse order by modification time.

ls /etc -alrt

This works the same as:

ls /etc -lt -c -r

Is there a reason to use the former as opposed to the latter, besides it being shorter? Also seems to use different flags
Whilst various ls implementations have become more and more crufty and hybrid over the decades, they're not the same.

http://unixhelp.ed.ac.uk/CGI/man-cgi?ls
Last edited on
Yea that's the man page I read, but I'm not sure which one is "proper". They give me the same output.
You sure they're the same?

The -a flag for ls usually shows hidden files. So it'll show files prepended with a period and also the . and .. links for your current and parent directory.

The -l flag puts it in list format, with more details.

The -t flag is the sort by modification time flag.

The -r reverses that sort.

The -c I *think* sorts by modification time of the inode number, rather than the file.

It might just be coincidence that they show the same results, especially if you're listing a smaller set of files. When I run the commands on my box here, I get a different result for each.

I should note, I'm running ksh but I don't think that should make a difference.
Last edited on
diff <(ls /etc -alrt) <(ls /etc -ltcr)

Yea after digging around I found out that -c does not do what I want, and the output was a little different. Though it was pretty minimal
Some flags have a long (meaningful) equivalent.
Also you could pass arguments (that may be optional)
man 3 getopt
Topic archived. No new replies allowed.