Explaining Shell Commands in the Shell

Use the explain API to explain commands - from the command line!

Jackson Pauls By Jackson Pauls
$ explain 'ls -lh'

ls(1)
  list directory contents

  -l (-L)
    use a long listing format

  -h (-H, --HUMAN-READABLE)
    with -L and/or -S, print human readable sizes (e.g., 1K 234M 2G)

Neat?

(Update: there's now also an npm module.)

Here's the bash function behind this:

This uses an API to get text output from our recently introduced explain functionality.
Give it a quick spin:

curl -Gs "https://www.mankier.com/api/v2/explain/" --data-urlencode "q=tar -xf tarball.tar.gz"

Interactive mode looks like this (user input in bold):


$ explain
Command: ls -l

ls(1)
  list directory contents

  -l (-L)
    use a long listing format
                                           https://www.mankier.com/1/ls

Command: du -s * | sort -n | tail

du(1)
  estimate file space usage

  -s (-S, --SUMMARIZE)
    display only a total for each argument

  *
                                           https://www.mankier.com/1/du

-----------------------------------------------------------------pipe--

sort(1)
  sort lines of text files

  -n (-N, --NUMERIC-SORT)
    compare according to string numerical value
                                         https://www.mankier.com/1/sort

-----------------------------------------------------------------pipe--

tail(1)
  output the last part of files
                                         https://www.mankier.com/1/tail

Command: [ctrl+d] Bye!