I need urgent help - Basic shell scripts but I'm clueless.

 
Thread Tools Search this Thread
Operating Systems Linux Fedora I need urgent help - Basic shell scripts but I'm clueless.
# 1  
Old 09-24-2009
I need urgent help - Basic shell scripts but I'm clueless.

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?
# 2  
Old 09-24-2009
Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

URGENT Reading a file and assessing the syntax shell script URGENT

I am trying to write a shell script which takes an input file as an arguement in the terminal e.g. bash shellscriptname.sh input.txt. I would like for the file to be read line by line each time checking if the .txt file contains certain words or letters(validating the syntax). If the line being... (1 Reply)
Discussion started by: Gurdza32
1 Replies

2. Shell Programming and Scripting

Help on these basic scripts

1. Write a program 'suffix' that renames a file by adding the characters given as the second argument to the end of the name of the file given as the first argument. So..... suffix memo1 .sv should rename memo1 to memo1.sv. 2. Write a program called "t" that displays the time of day in... (0 Replies)
Discussion started by: rockyrajpal
0 Replies

3. AIX

Please update inittab/rc.shutdown/rc scripts to start/stop mqm (need help Urgent)

HI i need help from seniors on this issue, i need to know how to do this, i need to update 50+ server starting saturday. below is the ticket which i have with full description. Currently MQ Series must be stopped before and started after any reboot. Not having the start/stop as part of... (2 Replies)
Discussion started by: gulamibrahim
2 Replies

4. Shell Programming and Scripting

Changing the Bash Scripts to Bourne Scripts:URGENT

Hi, I have to write a program to compute the checksums of files ./script.sh I wrote the program using bash and it took me forever since I am a beginner but it works very well. I'm getting so close to the deadline and I realised today that actually I have to use normal Bourne shell... (3 Replies)
Discussion started by: pgarg1989
3 Replies

5. AIX

Examples of writing shell scripts for AIX, it's urgent

Please help me 1. Please give me the few examples of shell scripts written for AIX 2.I have scripts written on Unix, does that work for AIX, if not what are the changes to be carried out to run the scripts on AIX.... Please help me (4 Replies)
Discussion started by: me_haroon
4 Replies

6. Shell Programming and Scripting

basic c-shell help

hello, i am very new to this, so i have basic questions about writing a shell. if i am working with a basic file, "main.c" and a shell file, "shell", what will the shell file look like? i want to change the command prompt from % to $, and i want to be able to have standard input from the... (0 Replies)
Discussion started by: ayalex
0 Replies

7. UNIX for Dummies Questions & Answers

clueless - shell question

I am a Wintel Admin that was thrown to the wolves and told to admin a Sun 280R with Solaris 8 on it and I need some help. I am running a Sun One ASP server and trying to get Java setup. I am trying to run a Sevlet program that requires the JAVA_HOME environment variable to be set. I am... (14 Replies)
Discussion started by: RandySmith23
14 Replies

8. UNIX for Dummies Questions & Answers

clueless...advice please!

for more than 5 years i have used windows based operating systems and hardwear, but recently i have decided to venture into the world of unix systems. very recently infact- i dont own a unix system yet and was wondering about hardwear.. i was planning on buying a second hand system from ebay... (1 Reply)
Discussion started by: andyh411
1 Replies
Login or Register to Ask a Question