[lug] Newline in a filename

D. Stimits stimits at idcomm.com
Sun Nov 11 16:24:26 MST 2001


"Timothy C. Klein" wrote:
> 
> * D. Stimits (stimits at idcomm.com) wrote:
> > "Timothy C. Klein" wrote:
> >
> > The second possibility is to quote your file names, and for the newline
> > portion, precede with the "literal quote" sequence, control-v. So if you
> > hit control-g on a regular console (maybe on xterms, depends on setup),
> > you'd get a bell; if you use control-v control-g, then you'd see ^g and
> > it would not be interpreted. To quote return key, use control-v return.
> > The above sample might instead look like:
> > ls -aF "abc.txt^J".
> 
> I had forgotten about this trick.  I tried it, but I can't get it to
> work with the new line character.  I can insert © with ctrl-v in vi, I
> can instert a bel (ctrl-g), etc, but when I do ctrl-j or decimal 10 I
> get the actual new line, rather than an escaped version.  Curious.  I
> guess it is a perl script or wild cards then.

This might be some sort of snag with your shell. But I've tested
control-v <enter>, and it shows up as a literal ^J. There is of course
another possibility under some circumstances that you really have \0x0A
or \0x0D, or a combination; newline (linefeed) versus carriage return,
versus both. I would strongly suspect that it is just a linefeed, rather
than the others, but if at some point a non-linux app touched your
script it could be a problem. Something else you might want to do is
redirect the output of "ls -al" into a file and edit the file under vi;
while editing, tell it to show hidden characters. E.G.:
ls -al > deleteme.txt
...then edit deleteme.txt with vi, and while in vi:
:set list

You'll then see a $ at end of normal unix EOL, or a ^M for windows
carriage return. Now whether or not control-v <enter> fails to show up
literally might be a shell issue, I'm using tcsh, but this has always
worked for me in bash. If you are inside of X11 at the time, X11 could
be doing some remapping that goes beyond what your shell would do (try
on a regular text console some time if previous failures were from X11).

D. Stimits, stimits at idcomm.com

> 
> Tim
> --
> ==============================================
> == Timothy Klein || teece at silverklein.net   ==
> == ---------------------------------------- ==
> == "Hello, World" 17 Errors, 31 Warnings... ==
> ==============================================
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug



More information about the LUG mailing list