Home > Software design >  How to see full manual for commands in terminal for Mac OS?
How to see full manual for commands in terminal for Mac OS?

Time:12-02

I am completely new to Mac OS and I am trying to figure out how to display in terminal all flags for echo command. When I do man echo it only shows me one flag which is -n and I am pretty sure there are many more. I've googled it but found nothing.

Thank you beforehand!

CodePudding user response:

For shell builtins such as echo, the man page does not offer an accurate description, since it describes the binary (usually found in /bin), not the builtin.

For help on the built-in commands in Bash, use

help echo

For instance, on my version of macOS this shows me:

echo: echo [-neE] [arg ...]
    Write arguments to the standard output.

    Display the ARGs, separated by a single space character and followed by a
    newline, on the standard output.

    Options:
      -n  do not append a newline
      -e  enable interpretation of the following backslash escapes
      -E  explicitly suppress interpretation of backslash escapes
…

In zsh, the closest equivalent is man zshbuiltins, which shows the documentation for all built-in commands. To find a given command in it, type / echo and hit Return. Note that there are multiple spaces between / and echo! This isn’t necessary, but it often filters out false hits.

CodePudding user response:

echo is a function of your shell and it behaves differently if you have a different shell. zsh or more 'advanced' shells may support extra args, but i've for one not heard about other args to echo than -n (which removes the trailing newlines).

macos is closer to freebsd than linux and it comes bundles with bash (Bourne again Shell), but in normal scenarios you should only assume that sh or ash (in Alpine) is available. E.g. while you may be able to use extra flags for echo with a different shell, you shouldn't expect that shell to be available or default on a target system.

I think a better way to find out what you want is to google what you want echo to do and likely there'll be lots of ways described how to do that outside echo (printf, cat, tee or similar).

  • Related