'ls' question, splitting and files with spaces in their name...
Madison Kelly
linux-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org
Sat May 22 14:28:24 UTC 2004
As often happens, just after posting I saw the '-Q' switch which adds
double quotes to the file name so I can split on that first. I decided
to use 's/\n//' rather than 'chop' (which I had been using) and 'chomp'
because it seemed more intelligent to me. I couldn't see any way that
the $_ would not end in a newline but I figured it was better safe than
sorry so I wanted to cut only newlines instead of indescriminately
chop/chomp'ing.
Madison (who wishes to remind people that she is a n00b programmer and
open to critique!) :p
Jim Rootham wrote:
> Hi Madison
>
> Try adding the switch, then substituting a magic char for the escape-blank
> combo, then do the split. Check for magic char first if you're paranoid.
>
> BTW why s/\n// rather than chomp?
>
> Jim
>
>
>> My problem is that I am just straight splitting on spaces and some
>>files and directory names have spaces in them. I read the 'ls' man page
>>and the closest thing I could find was a switch to add an escape
>>character before the space but that would only be marginally helpful.
>>
>> What I need is some way to show the file or directory name with some
>>other character instead of a space so that the first split will leave
>>the file or directory name intact wherein after I could substitute the
>>space back.
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list