Sorry for the top-post, but...

It'd be helpful if you posted an example of the file you're trying to read. It's difficult to understand what you want to happen.

On Tue, 27 Jan 2015, Daniel Herrington wrote:

All,

I'm clearly doing something wrong, and clearly am missing something about
bash and awk interaction. My script:

#!/usr/bin/bash

echo "Starting script"
while read line
do
   for m in $line
   do
     echo "before testing: $line :: $m"
     host=$(awk '{ print "wtf:" $m }')
     echo "$line :: $m :: $host"
   done
done < $1

It reads a file and outputs the list of names in the file, and I though
would be like:
Starting script
before testing: foo :: foo
foo :: foo :: foo
before testing: bar :: bar
bar :: bar :: bar
before testing: baz :: baz
baz :: baz :: baz
before testing: bunt :: bunt
bunt :: bunt :: bunt

However, what I get is:
Starting script
before testing: foo :: foo
foo :: foo :: wtf:bar
wtf:baz
wtf:bunt

I have isolated it to the awk command printing out the actual file
contents. However, I'm not sure how awk is looping through anything, as it
only should should have access to $line, and $line is a single line from
the file. It seems like awk is not in the loop?

thanks,



--
Paul Heinlein
[email protected]
45°38' N, 122°6' W
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug

Reply via email to