Implement the basename utility, which writes the last component of its pathname argument to standard output, as a bash function. For example, given the pathname a/b/c/d, basename writes d to standard output:

$ basename a/b/c/d
d

The following function is named bn to distinguish it from the basename util-
ity. It behaves the same way as basename.

$ function bn () {
> if [ $# = 0 ]; then
> exit 1
> elif [ "$1" = "/" ]
> then
> echo /
> else
> echo $1 | sed 's:.*/::'
> fi
> }

Computer Science & Information Technology

You might also like to view...

A key feature of TCP is its reliability. Define reliability

What will be an ideal response?

Computer Science & Information Technology

type of JList selection mode would allow the user to select March, June and July in one step?

January February March April May June July August September October November December a. SINGLE_SELECTION. b. SINGLE_INTERVAL_SELECTION. c. MULTIPLE_INTERVAL_SELECTION. d. All of the above.

Computer Science & Information Technology