Question: Write a C program that can traverse a tree of subdirectories and search for a file with a given name. myfind accepts the following parameters:

Write a C program that can traverse a tree of subdirectories and search for a file with a given name.

myfind accepts the following parameters:

$ myfind filename startpath

where

filename is a substring that is matched against each filename in each directory that myfindinspects. If a file name matches filename or if the substring filename occurs within a file name, the name of that file is printed.

startpath is an optional parameter that specifies the directory where myfind must start the search. If this parameter is not specified, myfind starts in the current directory.

For each file whose name is a match, myfind must print its name and its mode.

For each directory in which myfind finds a match, it must print that directory's full path.

$ myfind test /users/mark/home test.c (0644/-rw-r--r--) test.o (0755/-rwxr-xr-x) testfile.txt (0644/-rw-r--r--) mytest.c (0644/-rw-r--r--)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!