I have these two projects due tomorrow for extra credit in my Unix class and I have no idea how to write them. I really need the extra credit to bump my grade up a little. Any help would be greatly appreciated. Here are the descriptions:

Project One: A) Create a shell script called "add_listing" that prompts the user to enter a line of text and then appends it to the end of a file called "pbook"
B)Create a shell script called "find_listing" that prompts the user to enter a search string and then displays all lines from the "pbook" file that contain the entered string. The output should be stored.
C)Combine the above two scripts into a single script that will accomplish both of the above tasks depending on how it's invoked.

Project Two: A)Create a shell script that recieves the name of a directory as its argument and searches for any zero-length files within that directory. The script should display the names of these files.
B)Modify the above script to search not only the directory, but any sub-directories (and sub-sub-directories) as well.
C)Modify the above script to prompt the user for each file, asking if they wish to delete the file. The permissable responses should be 'Y', 'y', 'N' or 'n'. If 'Y' or 'y' delete the file. Otherwise, leave the file in place.

I have tried to do these over the past day or so but I haven't gotten them to work. If someone could help quick that'd be great. Thanks!

Recommended Answers

All 3 Replies

And what exactly have you done, and where/why doesn't it work?

Just a skeleton outline of the scripts would be helpful because I really don't know where to start besides #/bin/sh at the top...lol. I've read chapters 10 and 11 in my book but I'm still having problems. Like I said, it's extra credit, so we didn't go over how to do it in class. Please help quickly...Thanks!

echo "some prompt" - displays a prompt
read variablename - reads input from the terminal
echo "$variablename" >> filename - appends a line

Now you put them together.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.