Questions tagged [mv]
mv is a Unix command that moves a file to a target location.
660 questions
5
votes
6
answers
1k
views
Why can't I merge folders by renaming one of them?
Try to run this
mv -- "foldername...__" "foldername..."
This will move folder foldername...__ under the folder foldername... instead of renaming it. Why?
Note that foldername... ...
5
votes
2
answers
90
views
mv affected by bind mounts (feels like a bug)
Originally, mv(1) was a rename operation; it updated names in filesystems and did not copy files. More recently, a convenience feature was added, whereby if the source and target were on different ...
0
votes
1
answer
94
views
Help - I moved everything in the root directory to a directory of mine
So I was moving some files, I meant:
mv ./* ~/something
But I typed:
mv /* something
Now I can't boot up my computer and I couldn't because me: ls output: -bash: /bin/ls: No such file or directory
...
1
vote
6
answers
232
views
Move a lot of folders with spaces in the name
I have a lot of webpages saved in my Download folder and I want to move all html files together with its folder (for every "NAME.html" exists "NAME_files/" folder).
The big ...
4
votes
2
answers
369
views
Optimize rsync when large files move around on the source [duplicate]
Say I have a large directory tree of large files on disc A. I backup that tree with rsync -a --delete /A /B. So far so good. Between backups there are some added files, some renamed ones, the usual.
...
1
vote
1
answer
127
views
Why does my bash shell script not work in MacOS Terminal?
I have a bash shell script change_filename.sh containing the line of code:
mv "dir\ 1/file1.txt" "dir\ 1/file2.txt"
which does not change the name of file1.txt to file2.txt as ...
1
vote
1
answer
78
views
Recursively move and overwrite
I am using Ubuntu 24.10 and have a directory containing files and subdirectories:
main-dir
file1
file2
file3
subdir1
file1-1
file1-2
subdir1-1
file1-1-1
...
0
votes
0
answers
256
views
How can I restore the /usr/lib/x86_64-linux-gnu folder?
I'm new to Linux and did something stupid. I'm using Kali and after apt-get update and apt-get upgrade, I encountered some issues. The desktop items were missing and windows no longer had a "bar&...
0
votes
1
answer
42
views
`mv dir/file1 ..` removed file completely
Being in ~/dir1, I wanted to move the file ~/dir1/subdir1/file1 into ~. I executed mv subdir1/file1 ... No error occured. ~/dir1/subdir1 is empty, but I cannot find the file file1. Not in ~ and not in ...
0
votes
1
answer
64
views
Where did i put my directory?
I wanted to move my World file from my Terraria Server and used
(I was currently in the .local directory)
sudo mv share/ /terraria because
I wanted to move the share folder into the terraria directory....
0
votes
0
answers
62
views
To copy using cp non-recursively if the '-a' option is already used
BSD cp:
-a Archive mode. Same as -RpP options. Preserves structure and
attributes of files but not directory structure.
-P No symbolic links are followed. This is the ...
0
votes
1
answer
119
views
To move files only; To copy folders only
Tested in Bash and Zsh:
copy nondot files | cp ~/dir1/* ~/dir2/
copy dot files | cp ~/dir1/.* ~/dir2/
copy both nondot and dot files | cp ~/dir1/{.,}* ~/dir2/
...
0
votes
0
answers
94
views
Why is `mv -f source target` so much slower than `rm -f target && mv source target`
I got a case where I need to overwrite some file with another and noticed a very significant slowdown when using "mv -f" if the target already exists and is being read. More specifically, ...
0
votes
5
answers
176
views
How can I move a subdirectory to overwrite the parent directory?
Let's say I run,
cd /tmp/
mkdir -p foo/bar/
echo test > foo/bar/1
Now I have a very simple
$ tree foo
foo
└── bar
└── 1
2 directories, 1 file
Now if I want to move foo/bar to overwrite foo, ...
3
votes
2
answers
470
views
Using zmv to batch rename files and resolve filename collisions
This is an approach to rename files to random filenames, suggested by Terdon. The advantage of this approach is that it automatically resolves filename collisions:
randomname() { base64 < /dev/...