On Thu, 2003-01-09 at 02:01, BigBrother (BigB3) wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> Sorry for this OT but I am trying for some hours to achieve a massive
> rename of files using a simple script and I have not success yet. I want
> to rename files like
> "RESULTS OF JAN 01 2002.txt "
> i.e. all the spaces, being substituted by '_', and the last space being
> completely removed [yes it has a space after the suffix]
> I tried to experiment with sed/awk and creating a sample sh script with
> for i in 'ls' ....
> but the i takes values of 'RESULTS' 'OF' 'JAN'. This means that it doesnt
> take the full filename as value, but parts of the filenames.
> Can u please suggest an easy way to implement the massive rename?
If you want to do it for all files in a directory:
# for file in *; do mv "$file" `echo $file | sed -e 's/ /_/g'`; done
should do the trick. I think Perl is overkill for something this simple.
Someone else suggested tr, which probably works, but I've had more
success with sed.
The information contained in this email is confidential.
If you are not the intended recipient, you may not disclose or use the
information in this email in any way.
Dark Blue Sea does not guarantee the integrity of any emails or attached
The views or opinions expressed are the author's own and may not reflect
the views or opinions of Dark Blue Sea.
Dark Blue Sea does not warrant that any attachments are free from
viruses or other defects.
You assume all liability for any loss, damage or other consequences
which may arise from opening or using the attachments.
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message