|
|
awk question
I am in the process of writing a script that would read input from a
file containing 2 columns and would screen out and list only the
columns that contain "0". e.g,.
col 1 col 2
3333 542
4321 0
5541 0
5555 432
so I would want
col 1 col 2
4321 0
5541 0
I am new to programing and would very much like input to get the
results: The script looke like
awk /^[0]$/ '{ print $1, $2 }' file > file1 2>&1
obviously the above is not working
Thanks
|
|
0
|
|
|
|
Reply
|
jawadhus
|
5/20/2004 5:15:57 PM |
|
In article <54078e50.0405200915.21fa7a4e@posting.google.com>,
Jawad H <jawadhus@lycos.com> wrote:
>I am in the process of writing a script that would read input from a
>file containing 2 columns and would screen out and list only the
>columns that contain "0". e.g,.
>
>col 1 col 2
>3333 542
>4321 0
>5541 0
>5555 432
>
>so I would want
>
>col 1 col 2
>4321 0
>5541 0
>
>I am new to programing and would very much like input to get the
>results: The script looke like
>awk /^[0]$/ '{ print $1, $2 }' file > file1 2>&1
>
>obviously the above is not working
>Thanks
awk '$1==0 || $2==0' infile > outfile
Chuck Demas
--
Eat Healthy | _ _ | Nothing would be done at all,
Stay Fit | @ @ | If a man waited to do it so well,
Die Anyway | v | That no one could find fault with it.
demas@theworld.com | \___/ | http://world.std.com/~cpd
|
|
0
|
|
|
|
Reply
|
demas
|
5/20/2004 6:27:46 PM
|
|
Jawad H wrote:
> I am in the process of writing a script that would read input from a
> file containing 2 columns and would screen out and list only the
> columns that contain "0". e.g,.
Yes, I know. You posted this question and got an answer 3 hours ago on
comp.unix.shell.
Ed.
|
|
0
|
|
|
|
Reply
|
Ed
|
5/20/2004 6:55:24 PM
|
|
Jawad H <jawadhus@lycos.com> wrote:
>I am in the process of writing a script that would read input from a
>file containing 2 columns and would screen out and list only the
>columns that contain "0". e.g,.
>
>col 1 col 2
>3333 542
>4321 0
>5541 0
>5555 432
awk '! $1*$2'
will do the job and even preserve your header.
Martin Neitzel
|
|
0
|
|
|
|
Reply
|
neitzel
|
5/21/2004 3:51:15 PM
|
|
|
3 Replies
94 Views
(page loaded in 0.186 seconds)
|
|
|
|
|
|
|
|
|