LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   "Writing scripts in unix" (https://www.linuxquestions.org/questions/linux-newbie-8/writing-scripts-in-unix-4175457558/)

abrandnewday 04-09-2013 06:59 PM

"Writing scripts in unix"
 
The whole scenario must be written inside your script. Take two weeks to complete this; you can email me questions and we can discuss general questions in class too before this is due.
Write a script that will take two command line arguments. The arguments should have integer values between 0 and 5.

We need to verify that the user of your script has entered two arguments: If NO arguments were entered print out a usage error telling the person what to enter and exit with a value of 1. If the user has specified some arguments, but not 2, print out a message telling the user that 2 arguments are required and exit with a value of 2.

If there are two arguments, verify that the two numbers are within the specified range: 0<= number <= 5. If not, print out an appropriate message and exit with a value of 3 (if the first number is out of range) or 4 (if the second is out of range). You do NOT need to check the second number if the first is out of range.

If the numbers are within range, print the sum of the two numbers entered and the remainder of dividing the sum by 3.

Now, if either argument is 0, add 1 to both numbers. Now use a while loop to print out the integer values from -3 to the product of the two numbers entered (or their modified values).

Ask the user to enter a filename. If the username is null, yell at the user and exit with a value of 5. If the filename does not exist, you should create an empty filename with that name. If the filename exists and is a directory, yell at the user and exit
with a value 6.

Now for the next case (hint hint) read in a number. If it is even, print out even, otherwise print odd.

Create 4 empty files named zip11, zip12, zip41, zip13. Now list all file names in your directory that start with the letters zip. Now rename all files in your directory that start with zip1 so that they start with newzip1 ( example ñ zip13456 would become newzip13456). Careful, wildcarding will not work, so do the brute force way.

David the H. 04-09-2013 07:29 PM

Quote:

Originally Posted by LQ Rules
Do not post homework assignments verbatim. We're happy to assist if you have specific questions or have hit a stumbling point, however. Let us know what you've already tried and what references you have used (including class notes, books, and searches) and we'll do our best to help. Keep in mind that your instructor might also be an LQ member.

If you have any specific questions concerning your project, we'll be glad to help, but we aren't going to do it for you. Show us what you've done so far, and tell us where you are having trouble, and we'll be happy to give you some pointers.

cbtshare 04-09-2013 07:31 PM

lmaoooo...

chrism01 04-09-2013 08:00 PM

As per David the H. :)
Bookmark/read
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/

jpollard 04-09-2013 09:43 PM

This is the second thread on the same problem. See: http://www.linuxquestions.org/questi...ng-4175457568/


All times are GMT -5. The time now is 03:35 PM.