Questions tagged [mv]

mv is a UNIX command to move a file to another directory or rename it.

159 questions
141
votes
11 answers

How to move all files from current directory to upper directory?

How to move all files from current directory to upper directory in linux? I tried something like mv *.*, but it doesn't work.
asksuperuser
138
votes
9 answers

How to move files and folders recursively on Linux?

Consider: ls -al ../public-back drwxrwxr-x 4 apache apache 4096 Apr 19 03:32 templates ls -al ../public-back/templates drwxrwxr-x 2 apache apache 4096 Apr 19 03:33 content drwxrwxr-x 2 apache apache 20480 Apr 20 06:14…
siliconpi
  • 2,827
  • 6
  • 27
  • 28
106
votes
7 answers

What happens if mv is interrupted?

What happens if the Linux mv command is interrupted? Say, I'm moving a whole directory to some other place and interrupt it while it's moving. Will the source directory still be untouched?
dehmann
  • 2,333
44
votes
4 answers

In bash, how can I rename a file without repeating the path?

Possible Duplicate: Reuse text on a bash command If I want to rename a file a few directories deep, how can I avoid repeating the path? For example: mv path/to/old_filename.txt path/to/new_filename.txt I'm wondering if there's a way to make…
Nathan Long
  • 27,435
39
votes
6 answers

Move all files from subdirectories to current directory?

How can I move the files contained in all subdirectories to the current directory, and then remove the empty subdirectories? I found this question, but adapting the answer to: mv * . did not work; I received a lot of warnings looking like: mv: wil…
Richard
  • 1,015
25
votes
7 answers

How to move only files in Unix

How can I move only the plain files (not the directories) from one folder in Linux to another folder using the mv command? I have tried mv * ~/, but it copied everything including the directories.
shorty
25
votes
4 answers

Replace existing folder with mv command

Apologies if this question has already been asked, I couldn't find anything… Lets say I want to replace 'oldstuff' with 'newstuff'. Basically re-naming to replace. I try using this command: mv ~/newstuff ~/oldstuff But that only moves the folder…
25
votes
5 answers

How can I move files with xargs on Linux?

I am trying this and it's not working: ls file_* | xargs mv {} temp/ Any ideas?
user1953864
22
votes
4 answers

Moving 2TB (10 mil files + dirs), what's my bottleneck?

Background I ran out of space on /home/data and need to transfer /home/data/repo to /home/data2. /home/data/repo contains 1M dirs, each of which contain 11 dirs and 10 files. It totals 2TB. /home/data is on ext3 with dir_index enabled. /home/data2…
Tim
  • 353
18
votes
9 answers

What is the fastest way to move a million images from one directory to another in Linux?

I have a million images that takes up 30GB of disk space that need to be moved from one local directory to another local directory. What would be the most efficient way to do this? Using mv? Using cp? Using rsync? Something else? I need to take…
Ryan
  • 445
18
votes
3 answers

Move a range of numbered files?

I've got 291 numbered files (starting at 001 - title and ending at 291 - title) that need moved into separate directories. (001 to 021 to folder 1, 022 to 053 to folder 2, they aren't necessarily the same number of files each time). I figured I…
Rob
  • 2,422
17
votes
9 answers

Move a list of files(in a text file) to a directory?

I have a list of files, with their full paths, one per line in a file "files.txt" I was trying to move all of those files from their original location to a new directory. I CDed into the directory where they live now and issued for file in…
Steve
  • 537
12
votes
2 answers

What happened when I "mv *"? No errors were shown and now only one folder is left. Why?

The command executed was "mv space *" in a folder with 14 GB of data. mv * du -hs is the same so where has the 14 GB of data gone? What have I done?
12
votes
2 answers

mv command confuses directory name with command option

I have a directory called --pycache--, which I need to move to __pycache__. Using the mv command in the following way, gives me the listed output. How can I use the CLI to do what I want? $ mv --pycache-- __pycache__ /bin/mv: unrecognized option…
user81557
  • 223
12
votes
2 answers

How to mv a folder in Linux retaining its mtime?

I am using CentOS 5.5 and would like to move a large amount of folders within one volume, retaining their mtime. The best solution I could find is like this: cp -p -r source/data target/ rm -rf source/data With over 1TB of data on a NFS share, the…
1
2 3
10 11