Basename - kbasename

This is the Korn shell version of the Unix basename command. It is used to return the last part of a pathname. A suffix can also be given to be stripped from the resulting base directory. The substring feature is used to get the basename and strip off the suffix.

					#!/bin/ksh
					#
					#     kbasename - Korn shell basename
					#
					# Check arguments
					if (($# == 0 || $# > 2))
					then
					print "Usage: $0 string [suffix]"
					exit 1
					fi
					# Get the basename
					BASE=${1##*/}
					# See if suffix arg was given
					if (($# > 1))
					then
					# Display basename without suffix
					print ${BASE%$2}
					else
					# Display basename
					print $BASE
					fi
				

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.87.196