For Programmers: Free Programming Magazines  


Home > Archive > AWK > April 2007 > awk pipes 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]

 

Author awk pipes question...
Mag Gam

2007-04-11, 6:57 pm

I am not sure if should use awk pipes in this manner, but here I go
anyway

command | awk '/expression/ {print $1}' gives me a list like this:
object1
object2
object3


I would like to do
command2 object1
command2 object2
command2 object3


Any advice?

TIA

Seb

2007-04-11, 6:57 pm

On 11 Apr 2007 08:29:53 -0700,
"Mag Gam" <magawake@gmail.com> wrote:

> I am not sure if should use awk pipes in this manner, but here I go
> anyway


> command | awk '/expression/ {print $1}' gives me a list like this:
> object1 object2 object3


> I would like to do command2 object1 command2 object2 command2 object3


[sorry for the line-wrapping]

Maybe a 'while' loop?


command | gawk '/expression/ {print $1}' |
while read file; do
command2 ${file}
done


--
Seb
Ed Morton

2007-04-11, 6:57 pm

Seb wrote:
> On 11 Apr 2007 08:29:53 -0700,
> "Mag Gam" <magawake@gmail.com> wrote:
>
>
>
>
>
>
>
>
> [sorry for the line-wrapping]
>
> Maybe a 'while' loop?
>
>
> command | gawk '/expression/ {print $1}' |
> while read file; do
> command2 ${file}
> done
>
>


This is a shell question, not an awk one, and there's a better shell
solution that doesn't involve awk at all so I suggest the OP post the
question to comp.unix.shell.

Ed.
wfw

2007-04-11, 6:57 pm

On Apr 11, 11:29 am, "Mag Gam" <magaw...@gmail.com> wrote:
> I am not sure if should use awk pipes in this manner, but here I go
> anyway
>
> command | awk '/expression/ {print $1}' gives me a list like this:
> object1
> object2
> object3
>
> I would like to do
> command2 object1
> command2 object2
> command2 object3
>


If I understand what you're asking, you want:

command | awk '...' | xargs command2


Adster43

2007-04-15, 6:46 am

http://Martha-Stewart-anal-action.o...hp?movie=148803
news.t-online.de

2007-04-15, 6:57 pm

Mag Gam wrote:
> I am not sure if should use awk pipes in this manner, but here I go
> anyway
>
> command | awk '/expression/ {print $1}' gives me a list like this:
> object1
> object2
> object3
>
>
> I would like to do
> command2 object1
> command2 object2
> command2 object3
>
>
> Any advice?
>
> TIA
>


command | awk '/expression/ {print "command2 "$1}'
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com