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 03-14-2017, 01:38 PM   #1
souchai
LQ Newbie
 
Registered: Jan 2017
Posts: 3

Rep: Reputation: Disabled
writing a awk script


How do you create an awk script file, myawkmax, that will read 6 numbers, determine which number is the largest one, and then display the largest number.

- the awk script of myawkmax, must include a self-defined function with 6 parameters. No awk built-in functions are allowed to be used in your script.

When test the script with at least following testing cases:
$ ./myawkmax 3 1 2 5 4 6 7
The largest number is 7

$ ./myawkmax -3 -1 -2 -4 -5 -6
The largest number is -1
 
Old 03-14-2017, 01:43 PM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,237

Rep: Reputation: 1653Reputation: 1653Reputation: 1653Reputation: 1653Reputation: 1653Reputation: 1653Reputation: 1653Reputation: 1653Reputation: 1653Reputation: 1653Reputation: 1653
LQ doesn't answer verbatim homework questions. See LQ Rules: http://www.linuxquestions.org/linux/rules.html

Show your work and ask a specific question and you will receive better answers and help.
 
4 members found this post helpful.
Old 03-14-2017, 02:10 PM   #3
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Rep: Reputation: Disabled
This should help a lot for beginners,
if not solve your (homework?) problem.

http://www.grymoire.com/Unix/Awk.html
 
1 members found this post helpful.
Old 03-14-2017, 02:11 PM   #4
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Rep: Reputation: Disabled
Quote:
Originally Posted by szboardstretcher View Post
LQ doesn't answer verbatim homework questions. See LQ Rules: http://www.linuxquestions.org/linux/rules.html

Show your work and ask a specific question and you will receive better answers and help.

Funny!
Giggle giggle giggle..
 
Old 03-14-2017, 02:35 PM   #5
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 8,444
Blog Entries: 13

Rep: Reputation: 3762Reputation: 3762Reputation: 3762Reputation: 3762Reputation: 3762Reputation: 3762Reputation: 3762Reputation: 3762Reputation: 3762Reputation: 3762Reputation: 3762
Hi souchai and welcome to LQ.

szboardstretcher may be correct with their thoughts about a possible homework question. To add to that, my same comments from your other awk question in the Programming forum: LQ members are not here to provide on demand code answers for you. Instead the forum prefers that you attempt to solve your problem and post what you've tried. If you have no idea how to write awk scripts, then ask for help at starting and then post some of your initial attempts.

Hi fanoflq, your first answer offering a helpful link for awk is perfect. Along the lines of the rules cited by szboardstretcher, please note that one of those cites to not post if you do not have something useful to say. So let's stay on topic and see if souchai can provide some additional feedback regarding their needs to accomplish their project.
 
4 members found this post helpful.
Old 03-17-2017, 05:14 AM   #6
sbaynes
LQ Newbie
 
Registered: Oct 2014
Posts: 28

Rep: Reputation: Disabled
awk is intended for processing input read from standard input or from files whose names are given on the command line.

So with ./myawkmax 3 1 2 5 4 6 7 either you have misunderstood the question or if that is how the question was worded you have been set a real nasty one.
 
  


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
writing command line and create a awk file souchai Programming 2 03-14-2017 02:28 PM
[SOLVED] call awk from bash script behaves differently to awk from CLI = missing newlines titanium_geek Programming 4 05-26-2011 10:06 PM
Help needed in writing awk script for xml source naren_0101bits Programming 7 10-02-2007 09:47 PM
writing awk script files bigmark Linux - Software 1 10-19-2005 11:33 AM
Help needed in writing Awk Scripts.. TheDarktrooper Red Hat 1 05-04-2004 07:49 PM

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

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