[plug] Remove first sp[ac]e in a filename
Christian Müller
mullerc at iinet.net.au
Wed Jul 11 18:15:14 WST 2001
Thanks for that everyone, that worked very well. Guess I should learn a bit
of Perl now :)
Christian
At 13:46 11/07/2001 +0800, you wrote:
>Anthony J. Breeds-Taurima wrote:
>
>>for i in * ; do
>> h=`echo $i | sed -e s/^ //`
>> if [ "$i != "$h" ] ; then
>> echo moving \"$i\" to \"$h\"
>> #mv $i $h
>> else
>> echo skipping $i
>> fi
>>done
>
>
>for i in \ *; do mv -v "$i" "$(echo $i|sed -e 's/^ //')"; done
>
>Does the following:
>
> * only treats files with leading spaces
> * doesn't strip embedded spaces
> * works everywhere (else the leading space gets stripped B4 the mv)
> (and filenames with embedded funnies break also)
>
> * has no hanging strings (unbalanced quotes)
>
> * fails if a filename contains a double-quote symbol
>
>Sorry, I've been (full disclosure: am) really busy, and then sick, and now
>both else I would have turned up last night. It sounded interesting.
>
>Cheers.
>
>
>
More information about the plug
mailing list