UNIX Command To Rename A File

by Vivek Gite on January 2, 2009 · 2 comments

How do I rename a file in UNIX?

The mv is a Unix command that renames one or more files or directories. The original filename or directory name is no longer accessible. Write permission is required on all directories and files being modified.

mv Syntax

You need to use the mv command to rename a file as follows:

mv old-file-name new-file-name

Examples

Open the terminal (bash shell prompt) and type the following command to list file names:

ls
ls -l

In this example, rename a file called data.txt to letters.txt, enter:

mv data.txt letters.txt
ls -l letters.txt

File is renamed so the following command will display an error on screen:

ls -l data.txt

Outputs:

ls: cannot access data.txt: No such file or directory

Suggested Readings:

Type the following command to read mv command man page:
man mv

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

{ 2 comments… read them below or add one }

1 ELie Harb August 25, 2011

Hi,
How can i read a multiples files from MF/Cobol, whose inside programs is assigned to read “file1″.
i am getting: 201108251343file1
201108251430file1
201108251740file1
Is there an routine to added the 3 files into one file1.
Many Thanks.

Reply

2 d October 21, 2011

cat 201108251343file1 201108251430file1 201108251740file1>file1

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 13 + 2 ?
Please leave these two fields as-is:
Solve the simple math so we know that you are a human and not a bot.




Previous post:

Next post: