[plug] Remove first spcae in a filename
Anthony J. Breeds-Taurima
tony at cantech.net.au
Wed Jul 11 09:52:21 WST 2001
On Tue, 10 Jul 2001, Christian Müller wrote:
> Hi,
>
> I have just created a bunch of files and unfortunatelly seem to have a
> space as the first charater. How do I remove this space considering that
> there are some files which do not have a space as a first character? Does
> anyone know on how I can do this on the bash shell?
-----
#!/bin/sh
cd /path/to/directory
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
-----
Once you're ahppy the the echos match what need to be done then un comment
the mv and noone will ever know about this little problem :)
Yours Tony.
/*
* "The significant problems we face cannot be solved at the
* same level of thinking we were at when we created them."
* --Albert Einstein
*/
More information about the plug
mailing list