LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-09-2013, 07:59 PM   #1
abrandnewday
LQ Newbie
 
Registered: Apr 2013
Posts: 3

Rep: Reputation: Disabled
"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.
 
Old 04-09-2013, 08:29 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
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.
 
Old 04-09-2013, 08:31 PM   #3
cbtshare
Member
 
Registered: Jul 2009
Posts: 610

Rep: Reputation: 42
lmaoooo...
 
Old 04-09-2013, 09:00 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
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/
 
Old 04-09-2013, 10:43 PM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,599

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
several shell scripts writing to same sqlite db getting "database is locked" error. BrianK Programming 3 07-08-2010 11:28 PM
Seeking for "Synchronise" and "patients" projects/scripts of Visual Basic LAN-Dominator.nl Programming 2 07-05-2008 08:21 PM


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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration