truncate directory names to certain length
Doran L. Barton
fozz at iodynamics.com
Wed May 16 09:14:37 MDT 2007
Not long ago, Wade Preston Shearer proclaimed...
> I have a directory full of directories that are all named in the
> following manner:
>
> #####_alpha_name
>
>
> I need them renamed to just:
>
> #####
>
>
> Is there an easy way via the command line to truncate them to just
> the first five characters (which would be just their ID number)?
I'd use the 'cut' command:
NEWNAME=`echo $FILE | cut -c1-5`
So, perhaps something like this:
for FILE in ?????_alpha_name
do
NEWNAME=`echo $FILE | cut -c1-5`
echo "$FILE => $NEWNAME"
mv "$FILE" "$NEWNAME"
done
--
fozz at iodynamics.com is Doran L. Barton, president/CTO, Iodynamics LLC
Iodynamics: IT and Web services by Linux/Open Source specialists
"When a passenger of the foot hove in view, tootle the horn; trumpet at
him melodiously at first, but if he still obstacles your passage tootle
him with vigor and express by word of mouth warning, 'Hi, Hi.'"
-- Seen in a Tokyo traffic handbook
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://plug.org/pipermail/plug/attachments/20070516/12e1b2b9/attachment-0001.pgp
More information about the PLUG
mailing list