Write a function that prints all filenames in a specified directory hierarchy without using either ls or find. Its output should be similar to the output of the find command:

$ myfind /users/pat
/users/pat
/users/pat/bin
/users/pat/bin/ksh
/users/pat/bin/lf
/users/pat/bin/pic
/users/pat/chapt1
/users/pat/chapt1/intro
/users/pat/rje
/users/pat/rje/filel
(Hint: Bash and Korn shell functions can be recursive.)


#!/bin/sh

# myfind - recursively list all files and directories
# from the specified starting point


function listfiles
{
for name in $(echo $1/*)
do
echo $name
if [ -d "$name" ] ; then
listfiles "$name"
fi
done
}

if [ -z "$1" ] ; then
listfiles $(pwd)
else
listfiles "$1"
fi

exit 0

Computer Science & Information Technology

You might also like to view...

If the value in B4 = 40, what is the result of =IF( B4>65, "Passing", "Failing")?

A) TRUE B) Failing C) FALSE D) Passing

Computer Science & Information Technology

The Sasser virus/buffer overflow attack spreads by copying itself to shared drives and emailing itself out to everyone in your address book

Indicate whether the statement is true or false.

Computer Science & Information Technology

?The _________ audio element attribute specifies whether and how the audio should be loaded when the page loads.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

The ____ error occurs when the contents of cells referred to by other formulas are deleted.

A. #VALUE! B. #N/A C. #### D. #REF!

Computer Science & Information Technology