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:
  1. 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.
  2. Field splitting (see Field Splitting) shall be performed on the portions of the fields generated by step 1, unless IFS is null.
  3. Pathname expansion (see Pathname Expansion) shall be performed, unless set -f is in effect.
  4. Quote removal (see Quote Removal) shall always be performed last.
As you see, parameter expansion happens before word splitting.

Here's the relevant section from the bash 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.
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:
Blank interpretation
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.
Now, 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?

As for "my" syntax:

< $file | wc -l
you erroneously put an extra pipe in there. Remove it, try again, and give yourself minus 1 point for bad copying.

You're right. Think it will help, removing that pipe? Let's find out!

$ echo "hello" > data1 $ echo "world" > data2 $ file="data1 data2" $ < $file wc -l bash: $file: ambiguous redirect
Nope. Guess my "useless cat" is still very very useful.

In reply to Re^7: Sort Large Files by Anonymous Monk
in thread Sort Large Files by Velaki

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.