 |
 |
Difficult Pipeline Problem
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Nov 2005
Status:
Offline
|
|
This is a very hard unix command which I could not perform..........here it is:
The file ~unx122/public/data.txt contains over 18,000 lines of text. Here are the first ten lines of the file:
pagination 20657 2740 28416 31090 18145
shiner 1695 2507 9964 14512 13122
cool 29210 23832 22861 25037 18722
entertain 16186 23873 5049 3781 15735
sandwiches 9407 61 10817 7342 18224
sustenance 27174 8344 331 18238 25000
humanitarian 29733 13594 5573 24760 20213
Gus 10371 20643 22256 28933 7187
promoting 24678 31046 5759 7005 29626
ethereal 4963 15542 12202 23911 31595
Each line contains a word and five numbers, each separated by spaces. There are no spaces or punctuation marks in any of the words; each word consists of only upper- and lower-case letters. All of the numbers are whole numbers (no decimals and no negative numbers). There are no leading zeros (extra zeros added to the start of the numbers).
************************************************** ***
From the file ~unx122/public/data.txt, select all of the lines that
have a word in column one that starts and ends with vowels
and have values between 1000 and 9999 in the third column.
Sort these lines in reverse order according to column 3, then
select lines 15 through 37. Finally, put these lines in
normal order according to column 1 and write them to the file
~/uli101_a2_output.txt (overwrite any data already in that file).
I have to create a command pipeline to perform this task, and an appropriate bash shebang line, then the command pipeline.
Anyone know what the command could be?
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
Does your textbook not cover this?
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Apr 2002
Location: case.edu
Status:
Offline
|
|
What Chuckit said.
Here are some commands to get you started:
(Last edited by Tesseract; Nov 29, 2005 at 03:37 PM.
)
|
pb 1440x960 | 1.67, 1.5, 128, 80 | leopard
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Nov 2005
Status:
Offline
|
|
You could do all of this with awk, and perhaps also with grep and sort. Sounds like you are being assigned the problem of writing a shell script.
Take it one step at a time. For example, figure out how to get all the words that start and end with vowels. This will involve regular expressions (easy ones).
By the way, are all computer programming excersizes this stupid?
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status:
Offline
|
|
Originally Posted by wgscott
You could do all of this with awk, and perhaps also with grep and sort. Sounds like you are being assigned the problem of writing a shell script.
Take it one step at a time. For example, figure out how to get all the words that start and end with vowels. This will involve regular expressions (easy ones).
By the way, are all computer programming excersizes this stupid?
It may be stupid... but it sounds like fun... 
|
"In Nomine Patris, Et Fili, Et Spiritus Sancti"
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
Originally Posted by [APi]TheMan
It may be stupid... but it sounds like fun...
Heh, all that piping between utilities always gives me a headache. I'll tell you this much: My shebang line would be #!/usr/bin/env ruby.
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Apr 2002
Location: case.edu
Status:
Offline
|
|
|
|
pb 1440x960 | 1.67, 1.5, 128, 80 | leopard
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Nov 2005
Status:
Offline
|
|
Originally Posted by [APi]TheMan
It may be stupid... but it sounds like fun...
I've never taken a programming class in my life, but if I were to teach one, I would say "here's a problem, here's the input, here's what I need." Then allow the student to solve the problem, rather than dictate the procedural approach.
I suppose it makes the assignment easier to grade, but I don't see any other merit.
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
Originally Posted by wgscott
I've never taken a programming class in my life, but if I were to teach one, I would say "here's a problem, here's the input, here's what I need." Then allow the student to solve the problem, rather than dictate the procedural approach.
I suppose it makes the assignment easier to grade, but I don't see any other merit.
The point is that you are supposed to be learning certain things. Allowing people to solve the problem through means unrelated to what they are supposed to be learning does no good.
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status:
Offline
|
|
Originally Posted by wgscott
I've never taken a programming class in my life, but if I were to teach one, I would say "here's a problem, here's the input, here's what I need." Then allow the student to solve the problem, rather than dictate the procedural approach.
I suppose it makes the assignment easier to grade, but I don't see any other merit.
I've taken several programming classes, but I've learned all my shell scripting from toying around over the years. I just get a kick out of sed, awk, grep, sort, etc... I love that crap. I guess I look at the original poster's problem description and start solving it in my head and it sounds like fun... hah. 
|
"In Nomine Patris, Et Fili, Et Spiritus Sancti"
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Apr 2002
Location: case.edu
Status:
Offline
|
|
Originally Posted by [APi]TheMan
I've taken several programming classes, but I've learned all my shell scripting from toying around over the years. I just get a kick out of sed, awk, grep, sort, etc... I love that crap. I guess I look at the original poster's problem description and start solving it in my head and it sounds like fun... hah.
Yeah, me too. As I read the problem I started writing regexen in my head.
I would choose ruby over the shell if I actually had to do something like that, but it's fun to try it 'the old fashioned way'.
|
pb 1440x960 | 1.67, 1.5, 128, 80 | leopard
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Nov 2005
Status:
Offline
|
|
I beleive the command looks something like:
#!/bin/bash grep -i^[aeiou] sort -r -k -37 | head | tail -23 >~uli101_a2_output.txt
anyone know what should be changed?
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Apr 2002
Location: case.edu
Status:
Offline
|
|
Originally Posted by netmaster
I beleive the command looks something like:
#!/bin/bash grep -i^[aeiou] sort -r -k -37 | head | tail -23 >~uli101_a2_output.txt
anyone know what should be changed?
Did you try that on some sample data? Then you would at least know what, if anything, it is doing wrong.
|
pb 1440x960 | 1.67, 1.5, 128, 80 | leopard
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|