LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Change the file names of two files (https://www.linuxquestions.org/questions/linux-newbie-8/change-the-file-names-of-two-files-913291/)

bashnoob 11-13-2011 06:52 AM

Change the file names of two files
 
Hi.
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.

Roken 11-13-2011 07:31 AM

The easiest way is to use an interim filename:

mv filename1.txt filename.tmp
mv filename2.txt filename1.txt
mv filename.tmp filename2.txt


All times are GMT -5. The time now is 11:15 AM.