Using rename, and cp to rename a file.

James Michael Fultz croooow at gmail.com
Wed Feb 24 05:12:41 UTC 2010


* Ray Parrish <crp at cmc.net> [2010-02-23 20:11 -0800]:
> Hello,
> 
> I get the following -
> 
> ray at RaysComputer:~/logs/IIS$ rename /home/ray/logs/IIS/Grapg.html Graph.html
> Bareword found where operator expected at (eval 1) line 1, near "/home/ray"
>     (Missing operator before ray?)
> syntax error at (eval 1) line 1, near "/home/ray"
[...]
> ray at RaysComputer:~/logs/IIS$ c[ Grapg.html Graph.html

rename on Ubuntu systems is a Perl utility that interprets Perl
expressions.  See the man page for details.  A basic example would be as
follows:

$ rename s/g/h/ Grapg.html
         ^      ^
         |       \- File argument
          \- Perl substitute expression

> Can someone please tell me what I am doing wrong here?
> 
> Thank you, Ray Parrish

For simple file or directory renames, the mv command is suitable.

$ mv Grapg.html Graph.html

A shorter form using brace expansion available in Bash or Zsh:

$ mv Grap{g,h}.html




More information about the ubuntu-users mailing list