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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
03-14-2017, 01:38 PM
|
#1
|
LQ Newbie
Registered: Jan 2017
Posts: 3
Rep:
|
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
|
|
|
03-14-2017, 01:43 PM
|
#2
|
Senior Member
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278
|
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.
|
03-14-2017, 02:10 PM
|
#3
|
Member
Registered: Nov 2015
Posts: 397
Rep:
|
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.
|
03-14-2017, 02:11 PM
|
#4
|
Member
Registered: Nov 2015
Posts: 397
Rep:
|
Quote:
Originally Posted by szboardstretcher
|
Funny!
Giggle giggle giggle..
|
|
|
03-14-2017, 02:35 PM
|
#5
|
Moderator
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,938
|
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.
|
03-17-2017, 05:14 AM
|
#6
|
LQ Newbie
Registered: Oct 2014
Posts: 28
Rep:
|
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.
|
|
|
All times are GMT -5. The time now is 04:35 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|