LinuxQuestions.org
Review your favorite Linux distribution.
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 08-11-2014, 08:37 PM   #1
otkam83
LQ Newbie
 
Registered: Aug 2014
Posts: 2

Rep: Reputation: Disabled
Shell Scripting practice


Hi guys,

I have a few questions to ask and would appreciate all relevant input. This might be easy for some but can somebody help answer some of these;

1. Write a shell script that takes three numbers as arguments and outputs to the screen the sum of these numbers.
2. Write a shell script that reads three numbers and outputs to the screen the sum of these numbers.
3. Write a shell script that takes three numbers as arguments and outputs to the screen the maximum of these numbers.
4. Write a shell script that takes three numbers as arguments and outputs to the screen the three numbers in sorted order. You are not allowed to use the "internal built-in sort function".
5. Suppose the file employee.txt contains the following lines:

100 Thomas Manager Sales $5,000 Auckland
200 Jason Developer Technology $5,500 Auckland
300 Sanjay Sysadmin Technology $7,000 Hamilton
400 Nisha Manager Marketing $9,500 Hamilton
500 Randy DBA Technology $6,000 Hamilton

a. Write an awk that prints the second and the last element in each line.
b. Write an awk that prints the number of lines where the fourth field is Technology.
c. Write an awk that prints prints the lines where the sixth field is Hamilton.

Cheers
 
Old 08-11-2014, 08:42 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 3,966

Rep: Reputation: 1210Reputation: 1210Reputation: 1210Reputation: 1210Reputation: 1210Reputation: 1210Reputation: 1210Reputation: 1210Reputation: 1210
Do we get your course credit?
 
1 members found this post helpful.
Old 08-11-2014, 08:45 PM   #3
notKlaatu
Senior Member
 
Registered: Sep 2010
Location: Lawrence, New Zealand
Distribution: Slackware
Posts: 1,075

Rep: Reputation: 725Reputation: 725Reputation: 725Reputation: 725Reputation: 725Reputation: 725Reputation: 725
Are you asking for these scripts to be written for you, or are you asking for help with a specific problem you are having?

Generally, I would say that yes, all of these scripts are possible.

1. & 2. Use the 'bc' or 'dc' command
3. Use comparison operators in BASH
4. Use comparison operators in BASH, in a loop
5a. Yes, awk can do these functions.

If you have a more specific question, maybe post that.
 
Old 08-11-2014, 08:52 PM   #4
otkam83
LQ Newbie
 
Registered: Aug 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
Yea Mate you can get the course credit if you feel obliged to it, If your not willing to help dont other commenting, I said all relevant input would be appreciated. Cheers
 
Old 08-11-2014, 08:54 PM   #5
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,686

Rep: Reputation: 1692Reputation: 1692Reputation: 1692Reputation: 1692Reputation: 1692Reputation: 1692Reputation: 1692Reputation: 1692Reputation: 1692Reputation: 1692Reputation: 1692
Hi,
Quote:
Originally Posted by otkam83 View Post
Yea Mate you can get the course credit if you feel obliged to it, If your not willing to help dont other commenting, I said all relevant input would be appreciated.
I think you should read the forum rules [1] regarding homework questions.

Cheers,

Evo2.

1. http://www.linuxquestions.org/linux/rules.html
 
1 members found this post helpful.
  


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
Linux Laptop for shell scripts practice and certification test donxu Linux - General 2 08-10-2014 08:34 PM
Command line/scripting practice sd37 Linux - Newbie 4 03-28-2014 10:12 AM
win32,shell code,shell programming,shell scripting? mr.cracker Linux - Newbie 4 07-12-2013 11:20 PM
bash best practice : scripting actions to be done in all current subdirectories billywayne Programming 4 08-01-2009 07:42 PM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 04:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:16 AM.

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
Open Source Consulting | Domain Registration