piped to awk: how to print vars outside of line-in loop
- From: "Colin Brace" <colin.brace@xxxxxxxxx>
- Date: 20 Dec 2006 11:08:19 -0800
Hi all,
I have been tinkering with a shell script that takes the output from a
program and pipes it to awk to extract certain items and format them
nicely. So far I have this:
[...]
mplayer -vo null -ao null -frames 0 -identify 2> /dev/null $VideoFile |
awk -F = '
/ID_/ {
if (index($0,"DEMUXER") > 1) Container = $2
else if (index($0,"CLIP_INFO_VALUE0") > 1) Encoder = $2
[...]
}
{
print "Encoder is: " Encoder
print "Container is:" Container
}'
This works, except of course the "print" statement is repeated for each
line piped to awk (at least that is what I think is happening). How do
I print the variables assigned in the first {} just once?
Also, is there any way of accessing the awk variables in the subsequent
lines of the shell script?
I am new to awk and your forbearance is appreciated.
Thanks.
--
Colin Brace
Amsterdam
.
- Follow-Ups:
- Re: piped to awk: how to print vars outside of line-in loop
- From: Ed Morton
- Re: piped to awk: how to print vars outside of line-in loop
- From: Bill Marcum
- Re: piped to awk: how to print vars outside of line-in loop
- Prev by Date: Re: Newbie-ish question about ( [ and [[
- Next by Date: Re: Newbie-ish question about ( [ and [[
- Previous by thread: Extracting a character from a string
- Next by thread: Re: piped to awk: how to print vars outside of line-in loop
- Index(es):
Relevant Pages
|