I need to know the UNIX command for "what is the option to output the version information of ls?" I think I could use

$ ls -1

but that would list everything.

closed as too broad by Rui F Ribeiro, Thomas Dickey, jimmij, αғsнιη, Archemar Jan 8 '18 at 13:58

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

ls --version

In most cases for GNU commands, --version is used after commands

  • ls --version does not work on my Mac. ls --version ls --version ls: illegal option -- - usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...] – Snowcrash Jan 15 at 14:11

You can print the footer line of a manual page with

PAGER='tail -n1' man command

Most commands include their version number at the start of this line. In your specific example of ls, things can be a bit strange.

For example, on my NetBSD system I see NetBSD 7.1 in that position, so it simply tells which version of the system it is from. GNU ls instead places the coreutils version in that position. The GNU variant also includes a --version flag, but it also provides only the overall coreutils version.

A commentary on --version:

Most if not all GNU software supports being passed a --version flag. This does not hold for non-GNU software, which includes the default implementations of most commands on several UNIX-like systems.

Further, because of this tradition the GNU implementation of echo does not comply with the POSIX standard, which states (excerpt from the manual):

Implementations shall not support any options.

Not the answer you're looking for? Browse other questions tagged or ask your own question.