Kernel Hacks & Weird Filenames

Roy Smith roy at phri.UUCP
Thu May 12 08:40:07 AEST 1988


gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
> Geez.  Haven't you heard of "pipes and filters"?  Pipe the output of "ls"
> into a filter [...]

	In this case, it's a little bit complicated since the filter would
have to be syntax-sensitive.  Just doing "ls | cat -v" is no good because you
want to escape \n in file names but not at the end of lines.  You probably
want to escape spaces in file names but no place else, etc.  I'm sure it's
possible to write some sort of sed command which takes:

-rw-r--r--  1 roy           491 Apr 27 14:01 calendar
-rw-r--r--  1 roy           817 May 11 13:15  foo bar

and correctly figures out that the second file name is " foo bar" and only
escapes those two spaces, but it would be ugly and difficult.  Try and make
that filter general enough to deal with the varient formats of "ls", "ls -l",
"ls -ls", "ls -lsi", and "ls -lsig" and it sure starts to look like building
control-character escapes into ls isn't such a bad idea after all.
-- 
Roy Smith, System Administrator
Public Health Research Institute
455 First Avenue, New York, NY 10016
{allegra,philabs,cmcl2,rutgers}!phri!roy -or- phri!roy at uunet.uu.net



More information about the Comp.unix.wizards mailing list