Modify the cdh function to filter out multiple occurrences of the same directory. The new function should work as shown

$ cdh –l
0 /users/pat
$ cdh
$ cdh
$ cdh –l
0 /users/pat
$


The following lines need to be added to the end of the cdh function:

inlist=0
for dir in "${CDHIST[@]}"
do
# comparing PWD to directory $dir
if [ "$dir" = "$PWD" ] ; then
inlist=1
fi
done

if [ $inlist -eq 0 ] ; then
# no existing match, adding PWD to the list
CDHIST[cdlen]=$PWD
fi

Computer Science & Information Technology

You might also like to view...

If a sender uses the stream paradigm and always sends 1024 bytes at a time, what size blocks can the Internet deliver to a receiver?

What will be an ideal response?

Computer Science & Information Technology

Each time an external company or system is involved:

A) the processes that handle each of the interactions should be partitioned into one program for security reasons. B) a new temporary data store must be used with a process to create the data store. C) the process that handles the interaction must be on a secure server. D) the process involved needs to be partitioned into a separate program.

Computer Science & Information Technology

In Linux, in which directory are most applications and commands stored?

a. /home b. /var c. /etc d. /usr

Computer Science & Information Technology

Which term refers to a program that monitors the types of Web sites you frequent and uses that information to generate targeted advertisements, usually pop-up windows?

A. Spyware B. Adware C. Macro D. Trojan Horse

Computer Science & Information Technology