Add this feature to the function you wrote for exercise 14.

The Linux basename utility has an optional second argument. If you give
the command basename path suffix, basename removes the suffix and the
prefix from path:
$ basename src/shellfiles/prog.bash .bash
prog
$ basename src/shellfiles/prog.bash .c
prog.bash


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

Computer Science & Information Technology

You might also like to view...

To shrink audio files to more manageable sizes, they can be converted into ____ formats.

A. compressed audio B. MIDI C. compressed data D. CD-DA

Computer Science & Information Technology

You copy custom forms to other projects using the ____ dialog box.

A. Resources B. Organizer C. Forms and Tables D. Index

Computer Science & Information Technology

Which statistic is most likely to be included in a network baseline report?

A. how many text files are in use B. hard drive utilization C. number of idle users logged in D. average RPM of system fans

Computer Science & Information Technology

Which character is used as a substitution variable in APEX?

A) & B) ; C) : D) *

Computer Science & Information Technology