Did you actually try those?
Yes I did. Did you?
$ echo "hello" > data1 $ echo "world" > data2 $ file="data1 data2" $ cat $file | wc -l 2 $ < $file | wc -l bash: $file: ambiguous redirect 0
I suspect not, because you'd need an "eval" in your script to get the shell to do another round of whitespace parsing after the variable is interpolated, and that's a Very Good Thing.
Really? I've been writing constructs of the form:
for a couple of decades. And now you're telling me it never worked???? Now, you're free to believe me, but may I quote from the beginning of perl's Configure?FILES="file1 file2 file3 file4 file5" for file in $FILES do ... something with $file ... done
No extra eval happening here.paths='/bin /usr/bin /usr/local/bin /usr/ucb /usr/local /usr/lbin' paths="$paths /opt/bin /opt/local/bin /opt/local /opt/lbin" paths="$paths /usr/5bin /etc /usr/gnu/bin /usr/new /usr/new/bin /usr/n +bin" paths="$paths /opt/gnu/bin /opt/new /opt/new/bin /opt/nbin" paths="$paths /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb" paths="$paths /bsd4.3/usr/bin /usr/bsd /bsd43/bin /usr/ccs/bin" paths="$paths /etc /usr/lib /usr/ucblib /lib /usr/ccs/lib" paths="$paths /sbin /usr/sbin /usr/libexec" paths="$paths /system/gnu_library/bin" for p in $paths do case "$p_$PATH$p_" in *$p_$p$p_*) ;; *) test -d $p && PATH=$PATH$p_$p ;; esac done
I hand out the Useless Use of Cat Award precisely because of code like yours, where a cat is indeed completely useless.
Well, my code works and your suggested alternative does not work. So I get two things: an award, and working code. Good for me.
In reply to Re^5: Sort Large Files
by Anonymous Monk
in thread Sort Large Files
by Velaki
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |