Hello. I am currently in a class dealing with shell scripts. I know some commands and get the basics of command line in Fedora 11. But the coding....I'm a bit lost. I was very ill for 2 weeks and missed a lot, much of which there are no notes provided.
I'm not asking you to do my homework, because this isn't an assignment for marks. But it's an assignment nonetheless and I WANT to understand it.
I need to make scripts of the following. But in the simplest form, please, we're still dealing with low-level stuff. You guys are experts - I just need you to write this up and tell me what's going on (I'm lost on some syntax)
1) Accepts text from command line, then reverses the order of the words but not the words themselves. i.e. "One two three four" displays "four three two One". If the command line argument isn't any words, an error message is returned and a value of 1 is returned to the O/S.
2)
Quote:
Write a shell script called read-write-access that can be used to list all regular files in a directory that you have both read and write access to. Processing must meet the following specifications:
1.Prompt the user to enter the name of a directory.
2.Verify that the user entered the name of a valid directory. If the user did not enter a valid directory name, display an appropriate message, set the return-code to 1 and bypass all further processing.
3.Loop through all files present in the specified directory and display the names of all files that are regular files that you have both read and write access to.
4.Keep track of the number of such files.
5.If the final file count is zero, you must set the return-code to 2 and display an appropriate message that includes the name of the directory (e.g. "Directory /bin does not contain any regular files with read-write access").
6.If any files were found, display a message that includes both the directory name and a count of the number of files with read-write access (e.g. "Directory bin contains 10 regular files with read-write access"). In this case the return-code must be zero.
3)
Quote:
This script will prompt the user for the name of a directory and display the total number of sub-directories in that directory and the names of the oldest and newest sub-directories in it.
The return codes of this script will have the following values and meanings:
1Successful completion
2The specified directory does not exist
3The specified directory does not contain any sub-directories
Your script must prompt the user for the name of a directory. If the user enters "~", ".", or "..", you must convert this to the corresponding absolute path name.
Verify that the user specified a valid directory name; else display the message "The specified directory <directory> does not exist" and set the corresponding return code.
If the user specified a valid directory, loop through the "files" in that directory and find out how many sub-directories it contains and display the names of the oldest and newest sub-directory.
Output will consist of one of the following messages:
·"subs: Specified directory does not exist"
·"subs: There are no sub-directories in directory <directory-name>"
·"subs: There is only one sub-directory in directory < directory-name>: <filename>"
·"subs: There are <number> sub-directories in directory <directory-name>
" The oldest sub-directory is: <filename>"
" The newest sub-directory is: <filename>"
I am so lost right now that it scares me. I am only well enough to return to school today, and I am expected to comprehend these things by tomorrow..... D:
Any lifesavers here?