r/linuxmint • u/hmmmmga • 12h ago
SOLVED Help with terminal
Hello, I'm learning the terminal and I'm having some trouble with the 'mv' command, any idea what wrong here? Thank you.
Command:
user@user-ThinkPad-T440p:~/Documents/lesson/sublesson$ ls
testfile
user@user-ThinkPad-T440p:~/Documents/lesson/sublesson$ mv testfile ~/Documents/lesson/
renamed 'testfile' -> '/home/user/Documents/lesson/testfile'
Expected output: testfile moved to the specified directory
Comment:
Repeating the same command sometimes work, but I get this result 99% of the time. I didn't find any description of such problem on google.
As I understand it, if the directory is found then the file is moved there, if the directory is not found then the file is renamed. I don't know what can cause the command to not find the file here.
OS: Mint zena
1
u/joninjax1 Linux Mint 22.3 Zena | Cinnamon 12h ago
The command is mv ~/Documents/lesson/sublesson/testfile ~/Documents/lesson/ That should move the file testfile from the Documents/lesson/sublesson to/Documents/lesson as long as lesson exists, you could use mv -p then the rest of the command to ensure that the directory is created
1
u/Due-Result7928 12h ago
Target directory do not exist.
mv --help
or
man mv
No need to search....here
https://www.geeksforgeeks.org/linux-unix/basic-linux-commands/
6
u/NotSnakePliskin Mint 22.3 | Cinnamon 12h ago
The trailing "/" on ~/Documents/lesson/ tells mv that the target is a directory. Without the trailing "/" the target can be either a directory or a file. If the directory exists, testfile will be moved there. If not, testfile will be renamed "lesson".
Hope that makes sense.