On Sun, 17 Aug 2008, David Wolfskill wrote:
[snipped]
will assign to foo the value of the bar variable form the last record
read (in FreeBSD 6.3-STABLE, at least), the following fails to do so:
foo=
cat $filename | while read bar ... ; do
...
foo=$bar
David Wolfskill wrote:
I am writing a (Bourne) shell script that is intended (among other
things) to obtain information from a command, such as:
netstat -nibd -f inet
by reading and parsing the output.
However, the obvious (to me) approach of piping the output of the
David Wolfskill wrote:
foo=
cat $filename | while read bar ... ; do
...
foo=$bar
...
done
echo $foo
A trick I've used to great advantage in bourne shell and bash for
passing multiple variables back is to produce small snippets of shell
script
As I thought while reading your message, awk seems to be
a good solution. Just a note:
On Mon, 18 Aug 2008 06:29:03 +0300, Giorgos Keramidas [EMAIL PROTECTED] wrote:
Would you
be ok with an awk(1) script instead of /bin/sh? It tends to be nicer
for this sort of thing, i.e.:
[...]
$
On Mon, 18 Aug 2008 14:33:05 +0200, Polytropon [EMAIL PROTECTED] wrote:
As I thought while reading your message, awk seems to be
a good solution. Just a note:
On Mon, 18 Aug 2008 06:29:03 +0300, Giorgos Keramidas [EMAIL PROTECTED]
wrote:
Would you
be ok with an awk(1) script instead of
I am writing a (Bourne) shell script that is intended (among other
things) to obtain information from a command, such as:
netstat -nibd -f inet
by reading and parsing the output.
However, the obvious (to me) approach of piping the output of the
command to the standard input of a while
On Sun, 17 Aug 2008 18:33:28 -0700, David Wolfskill [EMAIL PROTECTED] wrote:
I am writing a (Bourne) shell script that is intended (among other
things) to obtain information from a command, such as:
netstat -nibd -f inet
by reading and parsing the output.
However, the obvious (to me)
On Mon, Aug 18, 2008 at 06:29:03AM +0300, Giorgos Keramidas wrote:
...
You are right that feeding data to a looping construct through a pipe
may run in a subshell. The ``Single UNIX Specification'' says
Ah; thanks for the confirmation.
...
What I usually do in similar shell scripts