Linux - NewbieThis 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.
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.
if i filter on OPERATOR=SM and SPEC=5 then what I'd like to getout is
Code:
DATE TIME OPERATOR VERSION RUN_ID SPEC DTG FAIL END FEATURE_1 FEATURE_2 FEATURE_3 GOODNESS
12/04/2013 6:00:011.27 SM 2.6.8 6 90501 5 921996008.31 FALSE 5 0.711503131 5660093.929 6.22 0.91
12/10/2013 6:00:011.41 SM 2.6.8 4 90503 5 921996011.31 FALSE 8 0.91836074 5660103.492 0.53 0.88
12/10/2013 6:00:011.32 SM 2.6.8 4 90501 5 921996011.01 TRUE 1
12/13/2013 6:00:011.15 SM 2.6.8 4 90503 5 921996016.01 FALSE 2 0.922633758 5660109.457 7.05 0.96
the files that i'm trying to process are much much bigger but i think this little one covers all the cases
thanks so much guys!!!
tabby
sure no prob... does this help as far as text padding go:
Code:
awk 'NR == 1 || ( $3 == "SM" && $7 == "5" ) {printf("%-10s %-10s %-10s %-10s %-10s %-10s\n", $1, $2, $3, $11, $12, $5)}' tabbygirl.lst
DATE TIME OPERATOR FEATURE_1 FEATURE_2 RUN_ID
12/04/2013 6:00:011.27 SM * 5 6
12/10/2013 6:00:011.41 SM * 8 4
12/10/2013 6:00:011.32 SM 4
12/13/2013 6:00:011.15 SM * 2 4
also, can someone help me understand why 5 is matched against $7 eventhough it should be the $6 field ?
edit: oh i get it, i see that the fields are mis-aligned in the output for some reason...
is version supposed to have a space ?; does fail end with a number or does end begin with a number (or possible column heading missing between fail and end) ?
perhaps comma-delimited input would work better ?
Location: a warm beach, cool ocean breeze, nice waves, and a Margaritta
Distribution: RHEL 5.5 Tikanga
Posts: 63
Original Poster
Rep:
morning guys
my office mate said that both the 2.6.8 and the number immeadiately following 2.6.8 ( that would be the 6 in the first row ) are part of the VERSION. she said that the the 2.6.8 is a "known" and when i do a grep statement on all the files the 2.6.8 shows up in all of them, but the number following the 2.6.8 does change. so she thinks i can ignore the 2.6.8 no need to repeat it, and just keep the number following it.
i'm going to test out some of your all's help, and see what comes back.
many thanks, tabby
Last edited by tabbygirl1990; 01-21-2014 at 09:04 AM.
Location: a warm beach, cool ocean breeze, nice waves, and a Margaritta
Distribution: RHEL 5.5 Tikanga
Posts: 63
Original Poster
Rep:
smeezekitty, i know it's very powerful, Perl is pretty scary to me. i blunder my way through awk sed and bash getting lots of help from the guys here learning as i go and i am soooo very thankful to them!
unless i could sit through a class on Perl (and i don't know when i could), i can't see my learning it. for me Perl is kinda like i gladly appreciate the gifts!
As an alternative to padding may I suggest you also look at the column command. I find it quite useful to simply print from awk with a standard space separation and let column handle the formatting
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339
Rep:
Quote:
Originally Posted by tabbygirl1990
smeezekitty, i know it's very powerful, Perl is pretty scary to me. i blunder my way through awk sed and bash getting lots of help from the guys here learning as i go and i am soooo very thankful to them!
unless i could sit through a class on Perl (and i don't know when i could), i can't see my learning it. for me Perl is kinda like i gladly appreciate the gifts!
Perl isn't so bad. And any many applications its actually simpler than awk
wohooo look, i even added an if statement, now i'm a programmer i put in all the extra spces myself just to line everything up, but i need to learn how to do that too...
Code:
OPERATOR VERSION RUN_ID SPEC DTG FAIL END FEATURE_1 FEATURE_2 FEATURE_3 GOODNESS
SM 6 90501 5 921996008.31 FALSE 5 0.711503131 5660093.929 6.22 0.91
SM 4 90503 5 921996011.31 FALSE 8 0.91836074 5660103.492 0.53 0.88
SM 4 90501 5 921996011.01 TRUE 1 NaN NaN NaN NaN
SM 4 90503 5 921996016.01 FALSE 2 0.922633758 5660109.457 7.05 0.96
it is kinda tricky to figure out what goes into fmt[1] fmt[2] and the printf statements to get out the right stuff, but i think i'm ready to tackle the next bigger file of 53 columns - yikes!
Location: a warm beach, cool ocean breeze, nice waves, and a Margaritta
Distribution: RHEL 5.5 Tikanga
Posts: 63
Original Poster
Rep:
smeezekitty,
i'm not really a "programer" you can probably tell
i needed a job and i had a class at USC and i'm good in math, so they hired me. there's a guy here (well up in San Fransico) that can help, but he's not here very often, glad i don't have a demanding boss, so it's just me and my cube-mate, and she's less technical than me, but someday maybe???
so between work, apartment life, and playtime in the ocean, i'm one busy tabbygirl
but i do really really appreciate all the help you guys give and i think i'm learning a few "geekie" programmer things
fatal: not enough arguments to satisfy formating string '%s,%s,%s,%s,%s,%s ^ ran out for this one
if i just use the print 0 command, i get 29 headers and 6 columns of data, but i only want the 6 heeaders not the 29, so i know the logic is working because with print $0 it gives 29.
The error comes from not supplying any input to the printf command:
Code:
printf("%s,%s,%s,%s,%s,%s\n")
So here you have told printf that there will be 6 string items to print but you pass in none, ie after the last double quotes should appear 6 comma separated items.
i would also note that as they stand, neither of the other 2 printf commands would work either. Here you need to review the number of double quotes you have used and also note that you have no new line
in either so all data presented by these lines will be continuous.
Location: a warm beach, cool ocean breeze, nice waves, and a Margaritta
Distribution: RHEL 5.5 Tikanga
Posts: 63
Original Poster
Rep:
good mornig grail,
yep, thanks you, as always, you are absoluetly correct
the problem that i have is that the data files and awk scripts i write are not on a machine that's connected to the internet, and i'm not allowed to copy data files to an internet machine because of privacy rules. so i my only choice is to look at one screen and type on the other, and so sometimes i mis-type or forget to type stuff and i know how syntax specific awk, sed, and bash scripts are, sorry.
gave me everything in the first line, I was hoping (although i didn't know how it could as it's currently written) not to have to declare (other than as strings) the 6 fields that i want, that the script would ust pull the 6 header field's that align with the printf statments
so i guess i'll have to write the 6 header fileds out explicitly
thanks soooo much guys, muah,
tabby
Last edited by tabbygirl1990; 01-23-2014 at 09:41 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.