LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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, 09: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, 09:42 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 (pre-systemd)
Posts: 2,609

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

Rep: Reputation: 524Reputation: 524Reputation: 524Reputation: 524Reputation: 524Reputation: 524
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, 09: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, 09:54 PM   #5
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

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


All times are GMT -5. The time now is 02:30 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