1

man often doesn't contain the example of a command, or very little.

Such as scp:

NAME
     scp — secure copy (remote file copy program)

SYNOPSIS
     scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port]
         [-S program] [[user@]host1:]file1 ... [[user@]host2:]file2

This is hard to understand where to put source file and destination file, same as documents like this.

It is very clear and easy understand with an example and some description:

scp -r  user@source_machine:/user/Desktop user@remote_machine:/path/foo

And as zip:

NAME
       zip - package and compress (archive) files

SYNOPSIS
       zip  [-aABcdDeEfFghjklLmoqrRSTuvVwXyz!@$]  [--longoption  ...]  [-b path] [-n suffixes] [-t date] [-tt
       date] [zipfile [file ...]]  [-xi list]

Thanks it has exmaple zip -r foo.zip foo

The normal way I think is zip A into B, [zipfile [file ...]] maybe saying you can pack zipfile with other files too(on no-native speaker vision). Only the example can make that clear.

So I wonder if there is a command or tool can show me the example of a command.

  • I don't think there is any way to show an example other than googling it. Try typing "command" --help and see if that solves your problem. – James Aug 24 '16 at 3:05
  • @James I google every time when met unfimiliar command, then found some example help me out. It is a little waste time, I think it may be much more efficient if there are some command or tool can show exmaple directly. – Mithril Aug 24 '16 at 3:09
  • You can definitely use "command" --help to see uses for the code. Try typing in zip --help and see what it says. – James Aug 24 '16 at 3:11
  • @James I known, but usually "command" --help wouldn't help more than man command. I am not talking about every command, just the major widelly used command.(I know a lot of command from small project can only use --help, have to goole ), I just mention zip and scp as common widely used command for example.And zip --help is not as useful as man zip, no example there. – Mithril Aug 24 '16 at 3:17
  • I definitely agree with @Serg. There aren't much examples of codes otherwise. – James Aug 24 '16 at 3:24
5

Quite a long time, and I found some solutions:

tldr

PS: tldr support many clients (check readme on above repo). Especially the go client can work offline and provide all platform binaries : https://github.com/leighmcculloch/tldr/

enter image description here

cheat

eg

enter image description here

  • The linked documentation on the GO client does not mention that special GO tools are required when it should be build from source. Those tools are not part of the standard install of Ubuntu. They can be installed with sudo apt install golang. – CatMan Jan 16 at 13:34
2

Unfortunately,no.

Documentation is up to the developers, so it is their responsibility to include examples into man pages. Sometimes they do, sometimes they do not. For instance , find command has very lovely and extensive EXAMPLES section in its man page.

Tools for providing examples would be handy, but since there are millions of commands/programs for Ubuntu and Linux in general, developing such tool would be a considerable effort, on the level of Sisyphus. Simple approach is just search online for usage examples of whatever program you are trying to run. Books are also very handy resource. Many of books on Linux, Unix, shell scripting, etc - they provide lots of examples and more importantly usage context for those commands.

If you believe that the manual page for a particular tool should contain (more) examples, please file a bug report with its maintainers or developers on Launchpad or “upstream” or, better yet, submit a patch that adds these examples.

Your Answer

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

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