Re: [Wlug] Wlug Digest, Vol 80, Issue 1 - AWK
#!/bin/tcsh awk -F\| '$3 == "" {print}' < test.txt 109: ./awk.csh One|two||four|Five|Six One|two||four|Five|Six wlug-request@mail.wlug.org wrote:
Send Wlug mailing list submissions to wlug@mail.wlug.org
To subscribe or unsubscribe via the World Wide Web, visit http://mail.wlug.org/mailman/listinfo/wlug or, via email, send a message with subject or body 'help' to wlug-request@mail.wlug.org
You can reach the person managing the list at wlug-owner@mail.wlug.org
When replying, please edit your Subject line so it is more specific than "Re: Contents of Wlug digest..."
------------------------------------------------------------------------
Today's Topics:
1. Awk Null Field (Gary Hanley) 2. Re: Awk Null Field (Jorden M) 3. Re: Awk Null Field (Gary Hanley) 4. Re: Awk Null Field (Jorden M) 5. Re: Awk Null Field (Gary Hanley) 6. Re: Awk Null Field (Jorden M) 7. Re: Awk Null Field (Theo Van Dinter) 8. Re: Awk Null Field (Gary Hanley)
------------------------------------------------------------------------
Subject: [Wlug] Awk Null Field From: Gary Hanley <gary@hanley.net> Date: Tue, 1 Jun 2010 16:00:26 -0400 (EDT) To: Worcester Linux Users Group <wlug@mail.wlug.org>
To: Worcester Linux Users Group <wlug@mail.wlug.org>
Wow, what's wrong with me? I'm trying to parse a file to eliminate any line from the file to the output where a particular field is is null. The 8th field in this case.
I can't get it right! I haven't done an awk script in a long time but this should be simple stuff.
Basically I'm trying to do:
cat file | awk -F\| '$8 !~ <NULL expression> {print}'
Any help would be appreciated.
Thanks.
-- Gary
------------------------------------------------------------------------
Subject: Re: [Wlug] Awk Null Field From: Jorden M <jrm8005@gmail.com> Date: Tue, 1 Jun 2010 16:26:23 -0400 To: Worcester Linux Users Group <wlug@mail.wlug.org>
To: Worcester Linux Users Group <wlug@mail.wlug.org>
Just check NF.
On Tue, Jun 1, 2010 at 4:00 PM, Gary Hanley <gary@hanley.net> wrote:
Wow, what's wrong with me? I'm trying to parse a file to eliminate any line from the file to the output where a particular field is is null. The 8th field in this case.
I can't get it right! I haven't done an awk script in a long time but this should be simple stuff.
Basically I'm trying to do:
cat file | awk -F\| '$8 !~ <NULL expression> {print}'
Any help would be appreciated.
Thanks.
-- Gary _______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
------------------------------------------------------------------------
Subject: Re: [Wlug] Awk Null Field From: Gary Hanley <gary@hanley.net> Date: Tue, 01 Jun 2010 17:08:46 -0400 To: Worcester Linux Users Group <wlug@mail.wlug.org>
To: Worcester Linux Users Group <wlug@mail.wlug.org>
Thanks, but that won't help here. Maybe I should have mentioned the fields are delimited by "|" and there is more than eight fields per record.
I think this might be more complicated than I assumed. Thanks anyway.
-- Gary
On 06/01/2010 04:26 PM, Jorden M wrote:
Just check NF.
On Tue, Jun 1, 2010 at 4:00 PM, Gary Hanley<gary@hanley.net> wrote:
Wow, what's wrong with me? I'm trying to parse a file to eliminate any line from the file to the output where a particular field is is null. The 8th field in this case.
I can't get it right! I haven't done an awk script in a long time but this should be simple stuff.
Basically I'm trying to do:
cat file | awk -F\| '$8 !~<NULL expression> {print}'
Any help would be appreciated.
Thanks.
-- Gary _______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
_______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
------------------------------------------------------------------------
Subject: Re: [Wlug] Awk Null Field From: Jorden M <jrm8005@gmail.com> Date: Tue, 1 Jun 2010 17:14:36 -0400 To: Worcester Linux Users Group <wlug@mail.wlug.org>
To: Worcester Linux Users Group <wlug@mail.wlug.org>
What will happen if the field is null? Two pipes? Or will there be space in between?
On Tue, Jun 1, 2010 at 5:08 PM, Gary Hanley <gary@hanley.net> wrote:
Thanks, but that won't help here. Maybe I should have mentioned the fields are delimited by "|" and there is more than eight fields per record.
I think this might be more complicated than I assumed. Thanks anyway.
-- Gary
On 06/01/2010 04:26 PM, Jorden M wrote:
Just check NF.
On Tue, Jun 1, 2010 at 4:00 PM, Gary Hanley<gary@hanley.net> wrote:
Wow, what's wrong with me? I'm trying to parse a file to eliminate any line from the file to the output where a particular field is is null. The 8th field in this case.
I can't get it right! I haven't done an awk script in a long time but this should be simple stuff.
Basically I'm trying to do:
cat file | awk -F\| '$8 !~<NULL expression> {print}'
Any help would be appreciated.
Thanks.
-- Gary _______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
_______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
_______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
------------------------------------------------------------------------
Subject: Re: [Wlug] Awk Null Field From: Gary Hanley <gary@hanley.net> Date: Tue, 01 Jun 2010 17:22:05 -0400 To: Worcester Linux Users Group <wlug@mail.wlug.org>
To: Worcester Linux Users Group <wlug@mail.wlug.org>
There will be a space.
-- Gary
On 06/01/2010 05:14 PM, Jorden M wrote:
What will happen if the field is null? Two pipes? Or will there be space in between?
On Tue, Jun 1, 2010 at 5:08 PM, Gary Hanley<gary@hanley.net> wrote:
Thanks, but that won't help here. Maybe I should have mentioned the fields are delimited by "|" and there is more than eight fields per record.
I think this might be more complicated than I assumed. Thanks anyway.
-- Gary
On 06/01/2010 04:26 PM, Jorden M wrote:
Just check NF.
On Tue, Jun 1, 2010 at 4:00 PM, Gary Hanley<gary@hanley.net> wrote:
Wow, what's wrong with me? I'm trying to parse a file to eliminate any line from the file to the output where a particular field is is null. The 8th field in this case.
I can't get it right! I haven't done an awk script in a long time but this should be simple stuff.
Basically I'm trying to do:
cat file | awk -F\| '$8 !~<NULL expression> {print}'
Any help would be appreciated.
Thanks.
-- Gary _______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
_______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
_______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
_______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
------------------------------------------------------------------------
Subject: Re: [Wlug] Awk Null Field From: Jorden M <jrm8005@gmail.com> Date: Tue, 1 Jun 2010 17:24:38 -0400 To: Worcester Linux Users Group <wlug@mail.wlug.org>
To: Worcester Linux Users Group <wlug@mail.wlug.org>
So match "| |"? Or perhaps "|[ ]?|"?
Or will that not work?
On Tue, Jun 1, 2010 at 5:22 PM, Gary Hanley <gary@hanley.net> wrote:
There will be a space.
-- Gary
On 06/01/2010 05:14 PM, Jorden M wrote:
What will happen if the field is null? Two pipes? Or will there be space in between?
On Tue, Jun 1, 2010 at 5:08 PM, Gary Hanley<gary@hanley.net> wrote:
Thanks, but that won't help here. Maybe I should have mentioned the fields are delimited by "|" and there is more than eight fields per record.
I think this might be more complicated than I assumed. Thanks anyway.
-- Gary
On 06/01/2010 04:26 PM, Jorden M wrote:
Just check NF.
On Tue, Jun 1, 2010 at 4:00 PM, Gary Hanley<gary@hanley.net> wrote:
Wow, what's wrong with me? I'm trying to parse a file to eliminate any line from the file to the output where a particular field is is null. The 8th field in this case.
I can't get it right! I haven't done an awk script in a long time but this should be simple stuff.
Basically I'm trying to do:
cat file | awk -F\| '$8 !~<NULL expression> {print}'
Any help would be appreciated.
Thanks.
-- Gary _______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
_______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
_______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
_______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
_______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
------------------------------------------------------------------------
Subject: Re: [Wlug] Awk Null Field From: Theo Van Dinter <felicity@kluge.net> Date: Tue, 1 Jun 2010 17:48:32 -0400 To: Worcester Linux Users Group <wlug@mail.wlug.org>
To: Worcester Linux Users Group <wlug@mail.wlug.org>
Unless I'm missing something, you should just be able to do ... awk -F\| '$8 {print}'
On Tue, Jun 1, 2010 at 4:00 PM, Gary Hanley <gary@hanley.net> wrote:
Wow, what's wrong with me? I'm trying to parse a file to eliminate any line from the file to the output where a particular field is is null. The 8th field in this case.
I can't get it right! I haven't done an awk script in a long time but this should be simple stuff.
Basically I'm trying to do:
cat file | awk -F\| '$8 !~ <NULL expression> {print}'
Any help would be appreciated.
Thanks.
-- Gary _______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
------------------------------------------------------------------------
Subject: Re: [Wlug] Awk Null Field From: Gary Hanley <gary@hanley.net> Date: Tue, 01 Jun 2010 17:46:17 -0400 To: Worcester Linux Users Group <wlug@mail.wlug.org>
To: Worcester Linux Users Group <wlug@mail.wlug.org>
No, that doesn't work. Here's how I tried it.
My play file. Notice records two and four: One|two|three|four|Five|Six One|two||four|Five|Six One|two|three|four|Five|Six One|two||four|Five|Six One|two|three|four|Five|Six One|two|three|four|Five|Six
Here's the output. Should have returned two records: cat file.txt | awk -F\| '$3 = "| |" {print}' One two | | four Five Six One two | | four Five Six One two | | four Five Six One two | | four Five Six One two | | four Five Six One two | | four Five Six
And: cat file.txt | awk -F\| '$3 = "|[ ]?|" {print}' One two |[ ]?| four Five Six One two |[ ]?| four Five Six One two |[ ]?| four Five Six One two |[ ]?| four Five Six One two |[ ]?| four Five Six One two |[ ]?| four Five Six
I'm probably have to refresh myself with the regular expression stuff and build a script. Not a bad thing I guess. Somehow I just assumed checking for a blank field in awk was a no-brainer. Now I'm going to have to think. :-\
Thanks Jorden.
-- Gary
On 06/01/2010 05:24 PM, Jorden M wrote:
So match "| |"? Or perhaps "|[ ]?|"?
Or will that not work?
On Tue, Jun 1, 2010 at 5:22 PM, Gary Hanley<gary@hanley.net> wrote:
There will be a space.
-- Gary
On 06/01/2010 05:14 PM, Jorden M wrote:
What will happen if the field is null? Two pipes? Or will there be space in between?
On Tue, Jun 1, 2010 at 5:08 PM, Gary Hanley<gary@hanley.net> wrote:
Thanks, but that won't help here. Maybe I should have mentioned the fields are delimited by "|" and there is more than eight fields per record.
I think this might be more complicated than I assumed. Thanks anyway.
-- Gary
On 06/01/2010 04:26 PM, Jorden M wrote:
Just check NF.
On Tue, Jun 1, 2010 at 4:00 PM, Gary Hanley<gary@hanley.net> wrote: > Wow, what's wrong with me? I'm trying to parse a file to > eliminate any line from the file to the output where a particular > field is is null. The 8th field in this case. > > I can't get it right! I haven't done an awk script in a long time > but > this should be simple stuff. > > Basically I'm trying to do: > > cat file | awk -F\| '$8 !~<NULL expression> {print}' > > Any help would be appreciated. > > Thanks. > > -- Gary > _______________________________________________ > Wlug mailing list > Wlug@mail.wlug.org > http://mail.wlug.org/mailman/listinfo/wlug > _______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
_______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
_______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
_______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
_______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
------------------------------------------------------------------------
_______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
-- Steven Greenberg Email: steve@ssgreenberg.name 251 Holland Rd. Phone: (774)241-0095 Fiskdale, Massachusetts 01518-1231 Web: http://www.ssgreenberg.name Other Email: s.greenberg@ieee.org ssg@alum.mit.edu
participants (1)
-
Steven Greenberg