Jza Posted June 17, 2005 Report Share Posted June 17, 2005 Hi I've read the man but haven't got luck sorting a list by different parameters like Date, Name, properties (rxw), node etc. Also I want to know how can I list directories (folders) only. I've tried ls -d or ls --directories but didn't work, just got a /.. output. Quote Link to comment Share on other sites More sharing options...
theYinYeti Posted June 17, 2005 Report Share Posted June 17, 2005 From memory, the only relevant option I know for ls is -t, which will sort by date/time. Sorting by name is the default. For other kinds of sorts, I think you'll have to pipe the ls (ls -l actually) output into the sort command. To have the list of directories, there are two methods: ls -la | grep '^d' or find . -type d -maxdepth 1 -print Yves. Quote Link to comment Share on other sites More sharing options...
Hirogen2 Posted June 19, 2005 Report Share Posted June 19, 2005 From memory, the only relevant option I know for ls is -t, which will sort by date/time. Sorting by name is the default. For other kinds of sorts, I think you'll have to pipe the ls (ls -l actually) output into the sort command. There's -S for size, -t for time (as you mentioned), -r for "reverse what would normally be returned (including -S, etc.)", -Y for sort-directories-first (not in mainline coreutils), Sort entries alphabetically if none of -cftuSUXY nor --sort. So I guess you take a look at man ls. Directories only with said grep ^d Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.