There are several programs that are particularly useful in shell scripts. Some utilities (such as
basename) are really only practical when used in conjunction with other programs, and therefore usually don't find a place outside of shell scripts, but others, such as
awk, can be quite useful on the command line too.
If you need to strip the extension off of a filename or get rid of the directories in a full pathname, use the
Try these examples on the command line to get a feel for how the command works:
basename example.html .html basename /usr/local/bin/example
In both cases,
example. The first command strips the
.html suffix from
example.html, and the second removes the ...