I'm new to shell scripting, learning it independently, and I'm seeing a lot of scripts with a usage()
function. For example:
usage()
{
echo "Usage: $0 filename"
exit 1
}
Which kind of functions should be called usage
? And is there relation to "usage statement"? I couldn't find any basic definition for this...
usage()
you can use aheredoc
see: Here Documents - The Linux Documentation Project. Which is often what you find when theusage()
gives detailed information on the script, along with a list of options and a description of each. It prevents using numerousecho
orprintf
statements one after the other...