Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-13-2011, 07:52 AM   #1
LQ Newbie
Registered: Nov 2011
Posts: 1

Rep: Reputation: Disabled
Change the file names of two files

I want to be able to easily change the file names of two files in bash shell.

Example: filname1.txt switch names with filname2.txt.
In this way, I want to transfer the contents of filname1.txt to filname2.txt and content of filname2.txt to filname1.txt
But I can not figure out how this can be done.
Old 11-13-2011, 08:31 AM   #2
Registered: Oct 2011
Location: Bolton, UK
Distribution: Arch local, Debian on VPS
Posts: 258

Rep: Reputation: 41
The easiest way is to use an interim filename:

mv filename1.txt filename.tmp
mv filename2.txt filename1.txt
mv filename.tmp filename2.txt
1 members found this post helpful.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Change file names ajs_box Linux - General 1 12-10-2006 04:47 PM
Script to change names of files in a directory geomonap Linux - General 2 12-03-2004 04:04 PM
How can i change names of multiple files? phz Linux - General 5 11-15-2003 11:06 AM
change file names to lowercase. david_wliu Linux - General 4 03-10-2003 02:17 PM
change file names to lowercase. david_wliu Programming 2 03-10-2003 01:59 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:30 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration