Page 1 of 1 [ 3 posts ] 

another_1
Veteran
Veteran

User avatar

Joined: 17 Jun 2010
Age: 65
Gender: Male
Posts: 528
Location: Columbia, SC

28 Oct 2010, 11:16 am

I'm taking a Unix class. Up until now, I've been getting c's in the class. Last night, we had a test - which I failed miserably, eliminating what little margin I had for error for the rest of the semester. Last night, we were also given an assignment, which we have to upload by midnight tonight, and I have NO idea how to begin. Thanks to my horrible test last night, I have to get a perfect grade on this (and all subsequent) assignments, or fail the course. I know I have to do a lot of studying and practice to get where I need to be, and I don't expect other people to do my homework for me, but there is no way that I can catch up to where I need to be in 12 hours.

The instructions for the assignment are to write a shell script which does the following:
- Prompt the user for a directory, or for the pwd, pr q! to quit
- Prompt the user for all or part of a filename
- Display, in the long format, all of the files, including hidden files, in the given directory including the given filename.
- Repeat until the user enters q!

If I can get the proper input from the user, I (think) I can display the proper directory listing, and I (think) I can loop it until the user enters q!, but I'm lost as to how to format the prompts themselves. :help:



mcg
Veteran
Veteran

User avatar

Joined: 26 Jan 2010
Age: 36
Gender: Male
Posts: 538
Location: Sacramento

28 Oct 2010, 2:18 pm

in bash?

it's just read variablename.

Code:
echo "Enter directory:"
read myDirectory
echo "Enter partial filename:"
read myFilename


then you just want to pipe the output of ls -al to grep with the partial name, pretty simple.



another_1
Veteran
Veteran

User avatar

Joined: 17 Jun 2010
Age: 65
Gender: Male
Posts: 528
Location: Columbia, SC

28 Oct 2010, 11:08 pm

mcg wrote:
in bash?
it's just read variablename.


Actually, while I realize that it is (still) dead simple, the assignment was a bit more than just that.

However, this was helpful, and I appreciate the response. Thanks!