Browsing articles tagged with "mv - Admins Goodies"
May 14, 2012
tom

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 is the right command to do so? Asked by gilzero This should do it: mv /directory_one/* /directory_one/.* /directory It will move regular files and dotfiles. Answered by Quinn Murphy Check more discussion of this question. Bookmark on Delicious Digg this post Recommend on Facebook […]

Continue Reading »
Mar 9, 2012
tom

*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? Asked by user533020 If the other process keeps the file open the entire time, then yes it should be able to continue reading. Just like you can delete an open file, and processes that file open will still be able to read/write from the file, until it closes. Answered by Zoredache Check more discussion of this question. Bookmark […]

Continue Reading »
Dec 6, 2011
tom

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 either in csv or any other text format. What I need to do is run a bash script and move or copy the files that are listed in the text file to another directory. Is there […]

Continue Reading »
Aug 20, 2011
tom

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 I might have: . |– FOLDER0 | |– SUBFOLDERA | `– SUBFOLDERB `– FOLDER1 `– AFILE.TXT And I want to convert it to: . |– folder0 | |– subfoldera | `– subfolderb `– folder1 `– […]

Continue Reading »
Aug 17, 2011
tom

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 subdirectory of itself” eg. I have: /src /new/dir/src /$ mv src/ new/dir/ If I delete the destination dir, then it works. I know I can move the contents of the source dir to overwrite the destination, but I’d […]

Continue Reading »
Aug 16, 2011
tom

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? Also, there is already a directory at ./members … I want to completely overwrite this directory, not just add the new contents to it. Directory Structure: ./ ./members ./members/srno ./members/srno/expired ./members/1 ./members/1/active ./members/members ./members/members/srno ./members/members/srno/expired ./members/members/1 ./members/members/1/active ./members/members/57364 ./members/members/57364/expired ./members/members/11939 ./members/members/11939/expired ./members/members/123 […]

Continue Reading »
Aug 9, 2011
tom

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 with different name: The following does work as expected, but is it possible to write a single command assuming there will be a lot of files to copy? cp /var/log/httpd/access_log /home/shantanu/access_log.bak cp /var/log/httpd/access_log.1 /home/shantanu/access_log.1.bak I think this should do the trick. for f in /var/log/httpd/access_log*; do cp $f /home/shantanu/$(basename $f).bak; done Check […]

Continue Reading »