Modify the cdh function to allow the user to specify a partial name of a directory in the history file preceded by a dash:

/etc: cdh –l
0 /users/pat
1 /tmp
2 /users/steve
3 /usr/spool/uucppublic
4 /usr/local/bin
5 /etc
/etc: cdh –pub
/usr/spool/uucppublic: cdh –bin
/usr/local/bin


The necessary code is added to the case statement just before the *) default case. Here's one way to add this feature, including an error message if there's no match found:
-[a-z]*) # find partial match in CDHIST
for dir in "${CDHIST[@]}"
do
if [ ! -z "$(echo $dir | grep "${1#-}")" ] ; then
# matched $dir, moving there
cdh $dir
return # done. uses first match
fi
done
echo "Error: No match for $1 found in CDHIST"
return ;;

Computer Science & Information Technology

You might also like to view...

Use the xrdb command to print the resource database of a running X server. Study the output to learn what types of applications use what types of resources.

What will be an ideal response?

Computer Science & Information Technology

The compression ________ indicates the reduction in size from the original size to the packed size

A) ratio B) measure C) quotient D) aspect

Computer Science & Information Technology

When grouping controls, a user can select the ________ layout format that mimics a paper form with labels to the left of each field

Fill in the blank(s) with correct word

Computer Science & Information Technology

The Form Footer section displays information at the top of each form.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology