Page 1 of 1

Listing options - again

Posted: 01 Apr 2015, 20:07
by viking60
The ls command lists stuff. And there are lots of tips out there how this could be done. Everybody has some preferences - which is fine.

The ls command can be combined with a ton of commands by using ls --

Like this

Code: Select all

ls --format=verbose


To check out what commands (besides --format) I have available I wrote

Code: Select all

ls --

And pressed tab (- NB I use ZSH I don't remember if you will get all the options in plain bash) and got the list:

Code: Select all

--all                                      -- list entries starting with .
--almost-all                               -- list all except . and ..
--author                                   -- print the author of each file
--block-size                               -- specify block size
--classify                                 -- append file type indicators
--color                                    -- control use of color
--dereference                              -- list referenced file for sym link
--directory                                -- list directory entries instead of contents
--dired                                    -- generate output designed for Emacs' dired mode
--escape                                   -- print octal escapes for control characters
--file-type                                -- append file type indicators except *
--full-time                                -- list both full date and full time
--help                                     -- display help information
--hide-control-chars                       -- hide control chars
--human-readable                           -- print sizes in human readable form
--ignore                                   -- don't list entire matching pattern
--ignore-backups                           -- don't list entries ending with ~
--inode                                    -- print file inode numbers
--kilobytes                                -- use block size of 1k
--literal                                  -- print raw characters
--no-group                                 -- inhibit display of group information
--numeric-uid-gid                          -- numeric uid, gid
--quote-name                               -- quote names
--recursive                                -- list subdirectories recursively
--reverse                                  -- reverse sort order
--si                                       -- sizes in human readable form; powers of 1000
--size                                     -- display size of each file in blocks
--tabsize                                  -- specify tab size
--time                                     -- specify time to show
--time-style                               -- show times using specified style
--version                                  -- display version information
--width                                    -- specify screen width
--dereference-command-line                 --format                                   --quoting-style                            --sort                                   
--dereference-command-line-symlink-to-dir  --indicator-style                          --show-control-chars 


That is a lot of options +1 (and these are not all)

And all of those options have a set of suboptions so to find out what the --format option had to offer I did a:

Code: Select all

 ls --format=

And pressed TAB and got these options:

Code: Select all

across         commas         horizontal     long           single-column  verbose        vertical 


So to show my listings with comma separation I would have to write;

Code: Select all

ls --format=commas

Yup - that works. It might not look all that peachy but it shows everything.

To check out what the --sort option had to offer i wrote

Code: Select all

ls --sort=
and pressed TAB and got these options

Code: Select all

~/ ls --sort=
extension  none       size       time       version 


That is handy so to list all your files by size you would do a

Code: Select all

ls --sort=size

Lots of options and I have no clue what you prefer - I am not sure what I prefer so ...