in reply to •Re^6: Sort Large Files
in thread Sort Large Files
Whitespace parsing happens before variable parsing in every bourne-ish shell I've used since the late 70s.
I guess the intersection of the sets of shells we have used is empty then. Anyway, here's the relevant portion of IEEE Std 1003.1. From section 2.6:
The order of word expansion shall be as follows:As you see, parameter expansion happens before word splitting.
- Tilde expansion (see Tilde Expansion), parameter expansion (see Parameter Expansion), command substitution (see Command Substitution), and arithmetic expansion (see Arithmetic Expansion) shall be performed, beginning to end. See item 5 in Token Recognition.
- Field splitting (see Field Splitting) shall be performed on the portions of the fields generated by step 1, unless IFS is null.
- Pathname expansion (see Pathname Expansion) shall be performed, unless set -f is in effect.
- Quote removal (see Quote Removal) shall always be performed last.
Here's the relevant section from the bash manual:
Of course you say "New fangled things! GNU, POSIX, who needs them! V7, that's what real men use." So be it. From the Unix V7 manual:The order of expansions is: brace expansion, tilde expansion, parame- ter, variable and arithmetic expansion and command substitution (done in a left-to-right fashion), word splitting, and pathname expansion.
Blank interpretationNow, I don't want to claim you are wrong, but if you have never programmed in the Unix V7 shell, GNU bash, or a POSIX compliant shell, which shells have you used since the 70s?
After parameter and command substitution, any result of substitution are scanned for internal field separator characters (those found in $IFS) and split into distinct arguments where such characters are found. Explicit null arguments ("" or '') are retained. Implicite null arguments (those resulting from parameters that have no values) are removed.
As for "my" syntax:
you erroneously put an extra pipe in there. Remove it, try again, and give yourself minus 1 point for bad copying.< $file | wc -l
You're right. Think it will help, removing that pipe? Let's find out!
Nope. Guess my "useless cat" is still very very useful.$ echo "hello" > data1 $ echo "world" > data2 $ file="data1 data2" $ < $file wc -l bash: $file: ambiguous redirect
|
|---|