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...

The ________ senses the closeness of the phone to the user's body and will turn off the touch screen when being held up to the ear during a conversation

Fill in the blank(s) with correct word

Computer Science & Information Technology

If a key pair is generated at a local computer, it is considered to be decentralized

Indicate whether the statement is true or false

Computer Science & Information Technology

You can select the page that appears in the browser window once a form is submitted using the ____ behavior.

A. Page Selection B. Log In User C. Recordset D. Insert Record

Computer Science & Information Technology

Which of the following is the wildcard used for any number of characters in SQL?

A) || B) # C) % D) &

Computer Science & Information Technology