On Mon, 17 Dec 2012 08:16:26 -0800
Devin Teske wrote:
>
> On Dec 17, 2012, at 3:39 AM, Jack Mc Lauren wrote:
>
> > Hi guys
> >
> > How can I read a file which contains a number and assign that
> > number to a variable via awk programming? By the way, I want to use
> > this awk program in a shell script.
> >
> > Thanks in advance
>
> Try this:
>
> awk -v file=/etc/ttys 'BEGIN { getline line <file; printf "First line
> from %s: %s\n", file, line }'
>
Semms a bit complicated when you could set the awk variable directly
e.g.
$ echo 42 > /tmp/f
$ awk -v x=`cat /tmp/f` 'BEGIN{ print x+1 }'
43
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[email protected]"