This was a very educational thread. Thanks for posing the question and the
summary, and thanks everyone for the useful answers. I don't have a need for
this just yet, but I have saved the thread as I am sure the answers will be
useful sooner or later.

I eagerly await the next educational thread. Who's going to ask the question?

Michael



On Tue, 14 Nov 2006, Maxim Vexler wrote:

On 11/14/06, Oded Arbel <[EMAIL PROTECTED]> wrote:
[snip]

 (IFS="$(echo)"; \
 for pair in `awk '/^[^[].+[^\n]$/ {print $1,$3}' passwd.fake`; do
 echo "$pair"; done)

 In the second example, I force the record separator to be only the new
 line character (the output from 'echo'. I can probably use \n, but I
 wanted to play it safe). Do mind the wrapping of the second form in
 parenthesis, otherwise you clobber your global IFS, which is something
 you want to avoid.

 --
 Oded
: : ..
 We make a living by what we get, but we make a life by what we give.
     -- Winston Churchill


Thanks to everyone for the help, all solution worked.
To sum up the tips:

By Oded Arbel:
a. Use a subshell to avoid mistakenly over riding your shell variables.
b. Use "$(echo)" as portable(?) newline variable scripting style.

By Ehud Karni:
a. Pipeing into bash subshell can be accepted inside the shell with read.
b. using a "while read VAR1 VAR2 VAR3..." is a convenient method to
accepting stdin data.
c. awk has system() !!

By Amos Shapira:
a. General work around is to construct the whole command as text, then
use either piping to sh or bash buildin "expr".

By Omer Shapira:
a. xargs -n switch can be used to "collect" variables separated by
either of [\n\t ].

By Valery Reznic:
a. set -- "space delimited word list" can be used as a quick method
for assigning value to number variables ($1..$9). [question: Really?
this does not seem to work for me].
b. bash while loop can get stdin from file IO redirection.

Ariel Biener doesn't understand the need for voodoo in modern life... ;)


Thanks guys for an educational thread.
Maxim.

--
Cheers,
Maxim Vexler

"Free as in Freedom" - Do u GNU ?

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]




=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to