Home > Archive > AWK > May 2004 > awk question
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Jawad H 2004-05-20, 2:30 pm |
| 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
| |
| Charles Demas 2004-05-20, 3:30 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
| |
| Ed Morton 2004-05-20, 4:30 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.
| |
| Martin Neitzel 2004-05-21, 12:30 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
|
|
|
|
|