Breaking large file into pieces

Larry Wall lwall at jpl-devvax.JPL.NASA.GOV
Thu Sep 13 02:19:53 AEST 1990


In article <24879:Sep1202:43:4690 at kramden.acf.nyu.edu> brnstnd at kramden.acf.nyu.edu (Dan Bernstein) writes:
: Larry:
: > Dan:
: > : Larry:
: > : > Dan:
: > : > : Larry:
: > : > : >     echo "$line"
:         [should be echo -n "$line$n" or echo -n "$line"; echo ]
:       [but that fails on \c machines ]
:     [preprocess with sed 's-\\-\\\\-g' or various others ]
: > But "hmph", yourself.  You still haven't posted "a solution that ALSO works
: > on all the \c machines."  Your -n solution doesn't work on a \c machine,
: > and your \c solution doesn't work on a -n machine.  At least it's symmetrical.
: 
: Oh, gimme a break. Your suggestion of switching to SVR4 doesn't work on
: any machine. :-)

True enough, but I wasn't suggesting that.  I was only asking you not
to suggest it.  I suggest we drop this one before someone else suggests
that we do so...

: It's trivial to select between the two scripts with an
: echo test. There: a perfectly portable sh solution to the problem that
: started this thread.

Ah, but as you know, I don't believe in fancy portability checks
in shell scripts...  :-)   :-)   :-)

The quibble still stands that echo isn't built into everyone's shell.

: > (By the way, what makes you think s/\\\\/\\\\\\\\/ is a solution?  It only
: > translates \\, not \c.)
: 
: Oh dear. Not paying attention to your quoting? sed s/\\\\/\\\\\\\\/ is
: translated by the shell into sed s/\\/\\\\/, which is translated by sed
: into s/\/\\/, which is what we want. \c becomes \\c, which is parsed
: (correctly) as backslash-c. What makes you think this isn't a solution?

Oops, you got me there.  It's not that I didn't see the non-quotes, it's
that I didn't see the "sed" on the front.  So I wasn't thinking of it as a
shell command.  (Odd, considering what newsgroup we're in.)  But it
just goes to show you the problems associated with remembering all
the multiple levels of interpretation that might happen.  At least in
my feeble brain.

We outlawed the "goto" statement where it reduced understanding.
Three or more backslashes in a row should be considered harmful.

Larry



More information about the Comp.unix.shell mailing list