Latest LQ Deal: Linux Power User Bundle
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 02-28-2016, 08:24 PM   #1
LQ Newbie
Registered: Feb 2016
Posts: 15

Rep: Reputation: Disabled
need help refining my command

I am in the CLI trying to move a file from a sub directory to another directory while changing the name of the file

If I am in the home directory now and am trying to pull a file from my Desktop directory while changing its name, should any of the following work?

mv file1.txt NewFile.txt /home/

mv file1.txt NewFile.txt | mv NewFile.txt ~

For some reason its not working out for me?
Old 02-28-2016, 09:10 PM   #2
Senior Member
Registered: Apr 2010
Posts: 1,455

Rep: Reputation: 253Reputation: 253Reputation: 253
mv <source> <destination>

if current path is:

try this:

mv file1.txt /home/NewFile.txt

if current path is:


try this:

mv /home/user/Desktop/file1.txt ./NewFile.txt

just make sure you have write permissions to /home directory

Good luck!!!
Old 02-29-2016, 01:43 AM   #3
Registered: Dec 2012
Location: Mauritius
Distribution: Slackware
Posts: 521

Rep: Reputation: 245Reputation: 245Reputation: 245
The simple mv command should do it very easily for you. In CLI mv is also used to rename a file like this:

> mv original_file.txt new_file.txt

So, if in addition you wish to move the file to another directory, you simply add the complete paths:

> mv original_file.txt NEW_PATH_TO_FILE/new_file.txt
Old 02-29-2016, 02:56 AM   #4
Senior Member
Registered: Dec 2008
Location: root
Distribution: Slackware & BSD
Posts: 1,665

Rep: Reputation: 488Reputation: 488Reputation: 488Reputation: 488Reputation: 488
Move and rename file in a single command of "mv" in the terminal.

Try this at your /home/you directory.

Create a file with content
echo "You and me." >> me
and check if it is created
ls me
and check what it has
cat me
You are certain the file exists.

Now move and rename it in a single command:
mv me Desktop/you
it momentarily stops then the prompt resumes in position. Now, recheck if the same file was copied and renamed into ~/Desktop folder
cat Desktop/you
There you are.

Hope that helps.

Good luck and enjoy.


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
Refining an alert notification script. Stepman 72 Linux - Newbie 1 11-18-2014 10:32 AM
ideas to refining this script adam_blackice Programming 2 09-10-2007 10:43 PM
Gentoo 2006.1 - Refining X Configurations indienick Linux - Desktop 11 04-17-2007 08:36 PM
LXer: Linux: Looking At 2.6.19, Refining the Development Process LXer Syndicated Linux News 0 09-23-2006 08:54 AM
Refining a Website ... mmertens Linux - Software 9 02-21-2003 03:05 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:14 AM.

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