Results 1 to 5 of 5
call me lazy... but how do I mv or cp a file to a new folder with the same name without having to manually re-type the file name?...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 10-13-2012 #1Just Joined!
- Join Date
- Jan 2012
- Posts
- 15
use mv to move file with same name
call me lazy... but how do I mv or cp a file to a new folder with the same name without having to manually re-type the file name?
- 10-13-2012 #2
I'm just as lazy... maybe lazier.
Just use cp.
That pretty much does the job.
Copies it right over. But you will always have to dictate the destination.Code:cp /home/this/folder /whatever/folder/here
Or you could go GUI and copy/paste.
*EDIT*
I just had a 'duh' moment... using the <TAB> button to auto-complete filenames cankeep you from having to type them out, as well.
Hope that made sense.Code:cp /home/this/folder /wh<TAB>(autofill)/fo<TAB>(autofill)/he<TAB>(autofill)
Last edited by jayd512; 10-13-2012 at 01:24 AM. Reason: see EDIT
Jay
New users, read this first.
New Member FAQ
Registered Linux User #463940
I do not respond to Private Messages asking for Linux help. Please, keep it on the public boards.
- 10-13-2012 #3Just Joined!
- Join Date
- Oct 2012
- Posts
- 11
use the tab key :/
- 10-13-2012 #4Just Joined!
- Join Date
- Jan 2012
- Posts
- 15
Thanks for the replies
I understand how to use tab but that would only work on the source parameter, understandably.
but I have to type the second sample.txt... which makes sense. How could the system "know" what I want.Code:kevin@kevcoder00:~$ mv dirs<TAB>ource/s<TAB>ample.txt dirdest/sample.txt
I was thinking more along the line of maybe some sort of text expansion or magic parameter
- 10-14-2012 #5Just Joined!
- Join Date
- Jan 2012
- Posts
- 15
OK I found what I was looking for... at least one way.
Code:kevin@kevcoder00:~$ mkdir dirsource; mkdir dirdest; touch dirsource/sample kevin@kevcoder00:~$ mysource=dirsource/sample ; mv $mysource dirdest/${mysource#*/} kevin@kevcoder00:~$ ls dirdest/ sample kevin@kevcoder00:~$ ls dirsource/ kevin@kevcoder00:~$



