Questions tagged [mv]

mv is a move/rename file in Linux

Filter by
Sorted by
Tagged with
47 votes
10 answers
152k views

Linux (mv or cp) specific files from a text list of files?

I have a directory of many files, something like 50,000 pdf's and other files on a server. I need to move specific ones to another directory. I can generate a list of the files that need to be moved ...
Jestep's user avatar
  • 643
34 votes
2 answers
27k views

mv, rename if exists

I need to assemble a lot of images into one directory. Many of those images have the same file names. Is there some safe version of mv that will automatically rename files if the target filename ...
theduke's user avatar
  • 600
20 votes
7 answers
4k views

Linux mv file with long name

In Linux I sometimes rename files like this: mv dir1/dir2/dir3/file.txt dir1/dir2/dir3/file.txt.old Note that I want to just rename the file, not move it to another directory. Is there a command ...
santiago arizti's user avatar
15 votes
1 answer
5k views

FREENAS: Why isn't mv command instant within a RAIDZ1 volume?

I'm currently 'reorganizing' file structure within a RAIDZ1 volume. Moving directories from one dataset to another, which are both contained on the same volume. SSH'ed into the machine and did a ...
Ryan's user avatar
  • 282
14 votes
6 answers
33k views

How to recursively move all files (including hidden) in a subfolder into a parent folder in *nix?

This is a bit of an embarrassing question, but I have to admit that this late in my career I still have questions about the mv command. I frequently have this problem: I need to move all files ...
deadprogrammer's user avatar
9 votes
3 answers
4k views

Is mv with wildcard still atomic

My understanding is that mv dir1/file1 dir2/ is atomic, Is mv dir1/* dir2/ also atomic? As an example, assume there are 10 files in dir1 that are 10GB each.
MR2Power's user avatar
6 votes
2 answers
26k views

What's faster for copying files from one drive to another? [closed]

Running linux. I have two identical drives mounted on the same machine. What is faster CP, MV, or RSYNC? Why is one faster than the other? Are there any faster alternatives?
T. Brian Jones's user avatar
4 votes
5 answers
569 views

How to rename libc.a back

I am working on AIX 6.1 and inadvertently renamed /usr/lib/libc.a to usr/lib/libc.a_ Just as I renamed I realized my stupid mistake. Almost all of the commands mv, cp, ftp etc ( except cd ) have ...
Pavan Manjunath's user avatar
4 votes
1 answer
4k views

mv fails but cp succeeds on nfs mount

I am trying to move a file from a local directory to an nfs mounted directory on a CentOS 7 server. The export is provided by FreeNAS. Both directories are owned by the current user with at least 755 ...
Jacob Tomlinson's user avatar
3 votes
6 answers
2k views

How to mass move files one directory up

I have about 200 directories in /home/. The problem is that they all exist in this way: /home/{user}/homedir/ While it should just be: /home/{user}/ With what command can I mass move all content ...
Sander's user avatar
  • 31
3 votes
1 answer
10k views

Command: move all files inside a directory to another directory (including hidden files)?

I tried to move all files inside a directory to another directory like this: $ mv /directory_one/* /directory However, the hidden files (such as .htaccess) in /directory_one won't be moved. What ...
gilzero's user avatar
  • 449
3 votes
1 answer
6k views

mv directory to overwrite another

I may be going bonkers here, but I'm trying to move a directory to a new location, overwriting the contents (on Linux, using bash). Everytime I try it, it responds with "mv: cannot move `./src' to a ...
gbjbaanb's user avatar
  • 3,902
2 votes
4 answers
4k views

move files from one device to another

I am trying to automate a remote backup on our centOS server, I run the current command : nice -n 10 mv -vfb /media/localbackup/* /media/remotebackup/ however when this is ran I get the following ...
Neo's user avatar
  • 187
2 votes
2 answers
94 views

*nix behavor, when overwriting a file that's open by another process using mv

Will the other process be able to finish reading the old file even though it's been replaced?
user533020's user avatar
2 votes
2 answers
3k views

How to perform the mv equivalent of yes | cp -rf on directories?

Using the below directory tree as an example, what is the best way to move the contents of directory/folderA to directory. How to overwrite a file if a file with the same name exists in the ...
Greg's user avatar
  • 1,657
2 votes
2 answers
2k views

linux shell script: how to move all sub folders with a given name?

I'd like to move all sub-folders starting with a given suffix (Blah_ in the example) into an other directory using a linux bash script. Here's what the script looks like: srcDir="/home/me/" ...
Tolaksa's user avatar
  • 165
2 votes
1 answer
41 views

mv: when is the resulting file available?

Suppose one process does this: mv a large file to a destination directory And another process is watching for that file in the destination directory because it wants to read its contents as soon as ...
user1011471's user avatar
2 votes
1 answer
903 views

NGINX and log rotation: is missing log entries possible?

In it's simplest realization, one can implement NGINX log rotation as following: mv access.log access.log.0 kill -USR1 `cat master.nginx.pid` My question. Do we have a concurrency issue here? I mean,...
user1065145's user avatar
2 votes
1 answer
1k views

CentOS - Accidentally Moved and Removed /home/ folders [closed]

I ran (stupidly) these commands: mv ncdu/ /home/* mv ncdu/ /var/* Trying to move the ncdu folder into these directories. And it caused me to remove all my Apache directories in my /home/ folder, ...
Moe's user avatar
  • 167
2 votes
0 answers
53 views

'reboot' command doesn't work properly after 'cp' command, 'mv' behaves weird, as well

I have compiled C code running as a binary on an ARM. The ARM boots Linux from an SD Card using an old Image that was generated using buildroot. Within the C code I call a shell script that moves the ...
sdepot's user avatar
  • 21
1 vote
2 answers
2k views

used mv command and my whole filesystem is missing

Alright, so I was in /var/www/forum/newrelease What I wanted to do was copy all of the files in newrelease to the directory forum, so I was thinking the command mv /* ../* would work, but now ...
Kelly Elton's user avatar
1 vote
2 answers
62 views

On Debian, what command will return the file with the "smallest" filename from a directory?

I have a directory containing three files, for example, 5.war, 6.war and 7.war. What command will return the file with the "smallest" filename from this directory? (In this case, 5.war.)
Jerome Ansia's user avatar
1 vote
1 answer
2k views

UNIX Copy/Move files in same directory preserving timestamp

Following is the scenario. There are multiple files in a directory created by users belonging to same unix group. Unix Group: Prod. User in Prod Unix Group: User1 User2 User3. All 3 users have same ...
Jolly J's user avatar
  • 21
1 vote
1 answer
825 views

Recovering original filename after renaming in Ext4

If I rename a file with mv command like: mv original_file_name new_file_name Is this possible to recover the original filename on Linux Ext4 file system and if so how that can be done?
user164863's user avatar
1 vote
2 answers
156 views

Delete all files via mv date?

Everyday new audio files are created in dir1. Sometime I move (mv) some files from dir1 to dir2 I want to delete all the files in dir2 that was moved before 20th June Is this possible?
I'll-Be-Back's user avatar
1 vote
2 answers
280 views

File move in Perl that stops the current script?

how can I do this mv ($file $new_file/$1) or die("Errors 2"); so it would stop the script in terminal if the file is not found? otherwise it keeps repeating and repeating and I need to restart putty ...
Treat's user avatar
  • 25
1 vote
3 answers
3k views

mass mv using find?

there are a bunch of filename.gif scattered in /home/ directories. I want all the filename.gif replaced by a /home/shared/filename_default.gif. I tried something like find /home/ -name "filename.gif"...
user avatar
1 vote
1 answer
535 views

Unix move folders with pattern

How can I move subfolders with a pattern to the new location? Example list of sources: /data/aaa/_old/ /data/bbb/_old/ The destinations should be: /archive/aaa/_old/ /archive/bbb/_old/ Is there a ...
Oliver's user avatar
  • 121
1 vote
1 answer
808 views

Detect USB driver plugged in and run a certain file on it

I have some kind of a kiosk Ubuntu set up based on Ubuntu Server 14.0.2 which runs an application on chrome. The kiosk has no internet connection thus the updates to the application should be done ...
kfirba's user avatar
  • 111
1 vote
1 answer
709 views

Error when using mv

I am receiving an error when trying to mv some files that really doesn't make sense. I receive this error: mv: cannot move `thatDir' to a subdirectory of itself, `/usr/local/apache-tomcat-6.0.32/...
Inversus's user avatar
  • 123
1 vote
1 answer
74 views

mved a lot of files to the same name - recovery possible

What exactly happens on file system level (ext4) when you mv one file over another file? Accidentally mved quite a lot of files over one other file. I wonder if it is possible to somehow restore the &...
Computerhirn's user avatar
1 vote
0 answers
438 views

The command "mv test_file TEST_FILE" fails with "mv: ‘test_file’ and ‘TEST_FILE’ are the same file" in a CIFS filesystem

I have a CIFS filesystem mounted in an Oracle Linux 7 server: //win-server/shared-folder on /data1/shared_folder type cifs (rw,relatime,vers=1.0,cache=strict,username=winuser,domain=mydomain.com,uid=...
Aurelio Martin Massoni's user avatar
1 vote
0 answers
73 views

LMD/Maldetect: Missing target-file operand after

After running mallet 1.5 in screen-mode (# maldet -a /var/www) I'm getting this return: maldet(6070): {scan} 618017/618044 files scanned: hits 0 cleaned/usr/bin/wc: /usr/local/maldetect/tmp/.sess....
MyFault's user avatar
  • 913
1 vote
1 answer
443 views

Remote rename of a file on Samba share via Bash script

I'm running a Bash script under Cygwin, but this question applies more broadly. I have a remote file: //someremoteserver/somefile.db That "//" path is under Cygwin--it's essentially a UNC pathname ...
Dan's user avatar
  • 61
0 votes
3 answers
5k views

How can I recursively change the case of files and folders under bash

I have some files and folders that are all in uppercase that I want to rename to their lowercase equivalent. What would be the best way to go about doing this in bash on a Linux system? As an example ...
David Dean's user avatar
0 votes
1 answer
307 views

SSH find directories with uppercase letters [closed]

Using SSH how can I find sub-directories that begin with uppercase letters within a directory and then rename them, including merging if the lowercase named directory already exists? e.g. if there is ...
John Mellor's user avatar
0 votes
3 answers
5k views

copy and rename files

Here are my access logs those I want to backup. /var/log/httpd/access_log /var/log/httpd/access_log.1 /var/log/httpd/access_log.2 /var/log/httpd/access_log.3 ... I want to copy all these files but ...
shantanuo's user avatar
  • 3,609
0 votes
1 answer
483 views

Variables on set-hostname and mv command in shell script

I have the below script in Shell: read n for ((i=1;i<=$n;i++)) do echo "Connecting to $publicip" ssh -i ./key.txt root@$publicip 'hostnamectl set-hostname autotest$i.domain.com && ...
serverstackqns's user avatar
0 votes
1 answer
2k views

Root cannot move files

I'm on Debian 5, I want to move files, but I'm getting a permission denied error, even if I'm root. Do you have any solutions? -rw-rw-rw- 1 scusr scusr 49901 Jun 17 09:04 ...
user178990's user avatar
0 votes
1 answer
3k views

Cannot move folder to a subdirectoy of itself - What's going on?

O.K I am trying to do the following very simple command and it is failing as follows... mv '/home/admin/Downloads/folder1' '/home/admin/MyLibrary/MyVideos/TV/folder1/' mv: cannot move `/home/admin/...
calumbrodie's user avatar
0 votes
3 answers
457 views

linux mv command weirdness

can anyone tell me why when I type: mv -f ./tmp/members ./ I get: mv: cannot move `./tmp/members' to a subdirectory of itself, `./members' And moreover the correct way to move this directory? ...
Eric's user avatar
  • 160
0 votes
1 answer
2k views

`mv` command did not rename, but move into existing directory, from ansible

I am running an ansible task (inside a role): - name: Rename dir become: yes shell: mv /data/files/1.6.5 /data/files/1.7.0 The intended effect is that 1.6.5 is renamed to 1.7.0 Now, on the target ...
transient_loop's user avatar
0 votes
1 answer
382 views

Bash: How to move files and directories from one directory to another?

I'm trying to write a script that moves files and (sub)directories from within one directory to another. That move operation should include not only regular files and directories but also any dot-...
Regis May's user avatar
  • 103
0 votes
1 answer
1k views

Bash Script To Move Files While Creating Directories

I've got this script to loop through all folders and move files that are more than 2 years old. I'm using the install command because it creates the necessary directories on the destination path and ...
Jeff C's user avatar
  • 1
0 votes
2 answers
41 views

used mv file.sql /folder instead of mv file.sql folder/

Hello I made the mistake of using mv file.sql /destinationfolder instead of mv file.sql destinationfolder/- using su root. Now I can't find my sql file. is there a way to find it/recover it?
nodejsj's user avatar
  • 103
0 votes
1 answer
354 views

Script to move Maildir contents to its parent dir but for multiple folders

I totally suck at Bash/Python/Ruby/Perl Scripting (need to practice/learn some more) so I'm asking for a little help :-) I need to move about the contents of about 60 Maildirs to their parent folder ...
Samuel Jones's user avatar
0 votes
1 answer
820 views

Permission denied with mv under apache

I have a bash cgi script called by apache which should move one file in /var/www/html to another in the same directory. I've set up the relevant permissions with selinux (e.g. chcon to ...
user avatar
0 votes
1 answer
54 views

Linux directory moved

a directory was moved with mv command in a Linux box, what logs should be looked at for such action? in root bash_history i can see the command was used, unfortunatly bash_history was not recording ...
Vlad's user avatar
  • 45
0 votes
2 answers
16k views

cannot move to a subdirectory of itself

I have 2 folders: /home/sphinx/articlesdb/ and: /home/sphinx/tmp/articlesdb/ I want to move and overwrite all of the files from tmp into the main folder. I am currently using: mv -f /home/sphinx/...
fire's user avatar
  • 113
0 votes
1 answer
1k views

Move files older than day

I am looking for some solution, where I have to move all the directories and files under the source directory to the destination a day before. I want to move the directories till yesterday but not ...
nasa's user avatar
  • 1