Jon Haugsand wrote:
Really? I haven't tried ksh on Linux other than seeing that it is there. However, I have recently done extensive (and portable) shell scripting in ksh on AIX (4 and 5), SunOS (5.6, 5.7, and 5.8) and HP-UX (11 and 11i) as well as Tru64 (AKA OSF1) and Linux. The script above works on all platforms except Linux. The ksh, BTW, is a free version whereas the ones on the other UNIXes are proprietary, of course, so there may be some incompatibilities.* [EMAIL PROTECTED]IFS=':' cat /etc/passwd | while read a b c d do if [[ "$a" == "root" ]] then export NAME="$c" fi done - in ksh this will export NAME into your current env, but not in bash. The explanation, I understand, is that when you start a pipeline in ksh, the last command in the pipeline (here: where ...) runs in the current shell, but in bash all the commands in a pipeline run in a subshell.This does not work in ksh on my RedHat 8.0. Neither shell do what you say.
That's a good tip - thank you! However, that only works if we're talking about 1 env variable. In my work it was actually a number of arrays, and I don't thik there's an easy way to implement that along the same lines. And a good tip in return: instead of `command` use $(command) - this notation can be nested!As I said this is only a minor annoyment, but it does mean that in bash you have to use an intermediate file: IFS=':' cat /etc/passwd > tempfile while read a b c d do if [[ "$a" == "root" ]] then export NAME="$c" fi done < tempfile rm tempfileAh no. You do it like this: NAME=`IFS=':' cat /etc/passwd | while read a b c d; do if [[ "$a" == "root" ]]; then echo $c fi done`
/jan
--
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list