Long form command line flags in Terminal?

I hope this is the right place to ask this question. So basically, I'm currently combing through some of the more commonly used Terminal commands, and I find it really hard to remember the short form flags vs. the long form flags.

For example,

ls -a

is much harder to remember for me than

ls --all

Obviously, this is trivial to remember for one flag, but given the number of programs executable through the shell and the available flags for each program, it becomes really, really hard to commit these to memory.

However, when I search through the man pages, for example,

man ls

The docs don't show the long form flags. For example, this is what I get

-1 (The numeric digit ``one''.) Force output to be one entry per line. This is the default when output is not to a terminal.
-A List all entries except for . and ... Always set for the super- user.
-a Include directory entries whose names begin with a dot (.).

I'm looking for something like this webpage:

-a, --all do not ignore entries starting with .
-A, --almost-all do not list implied . and ..
--author with -l, print the author of each file

but accessible offline.

I'm using MacOS, and running man through Terminal - are there any alternative manuals that do show the long form flags? I'd really appreciate it if someone could point me in the right direction.

Thanks!

1 Answer

The tool in general is man.

Ubuntu ls implementation is different than the one of macOS. If ls --all works for you but the man page in your OS doesn't list long options, then it will be wise to treat them as undocumented features that may stop working or change their meaning in the future.

Note that POSIX specifies only short options for ls. Preferring them over their long equivalents (if any) makes your "ls skill" more portable.

When checking if ls --all really works, do not confuse it with ls -all. The latter should be equivalent to ls -a -l -l, i.e. ls -a -l; it uses short options only and it will work in any POSIX-compliant system.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like