Tag Info

New answers tagged

0

Try bbcp. Testing in our environment revealed that cp had some sort of built in governer. Just be careful because when you take off the governer, you can red-line your server and cause an outage. In our case we were taking the server offline to do the copy, so faster was better. This improved transfer time several hours.


4

You can use shell globbing: for f in *.c; do cp -- "$f" "$OTHERDIR/old#$f"; done The for variable in GLOB format will expand the glob to all matching files/directories (excluding hidden-ones) and iterate over them, saving each in turn as $variable (in the example above, $f). So, the command I show will iterate over all non-hidden files, copying them and ...


8

a for loop: for f in *.c; do cp -- "$f" "$OTHERDIR/old#$f"; done I often add the -v option to cp to allow me to watch the progress.


6

To "install" a binary compiled from source the best-practice would be to put it under the directory: /usr/local/bin On some systems that path is already in your PATH variable, if not you can add it by adapting the PATH variable in one of your profile configuration files ~/.bashrc ~/.profile PATH=${PATH}:/usr/local/bin dd is a low level copy tool that ...


4

Install copies files with the default mode 755. Install can be configured to set the owner or group of a file and/or the mode of a file. Install can be configured to backup the original file before it is replaced.


0

cp -pu dir2/* dir1/* dir3/ from man: -p same as --preserve=mode,ownership,timestamps -u copy only when the SOURCE file is newer than the destination file or when the destination file is missing Note: Always put the updated directory first. (From example above: cp -pu dir1/* dir2/* dir3/ will not copy the updated files) dir3 must exist. ...


5

All you need is cp -n dir2/* dir1/* dir3/


3

Do I understand you correctly in that dir3 should contain all files from the two base directories, and if a file appears in both directories, the one from dir2 should be taken? Then a simple cp dir1/* dir3/ cp dir2/* dir3/ should do the trick: Files that differ in both source directories will be overwritten with the version from dir2. If you do not want ...


1

One way to do it: cp -a /path/to/dir2/* /path/to/dir3 cd /path/to/dir1 comm -23 <(ls -1 | sort) <(cd /path/to/dir2; ls -1 | sort) | cpio -pam /path/to/dir3 This assumes you only have files (i.e. no subdirectories) in dir1 and dir2, and your filenames don't contain newlines. It also assumes your shell is smart enough to handle <(...) constructs.


0

You can do it like this: cd -P files_input/.. && mkdir files_output && pax -rws'|.*/\(.*\)/\(.*\)|\1.\2|' \ files_input/??-2015/index.html files_output Which will glob all index.html files in folders in child directories of ./files_input named with two characters, then a dash, then the string 2015 and copy all of those files into ...


0

Try removing the quotes around {}, as seemed to work for me that way. $ find foo* files_output -ls 27002 0 drwxrwxr-x 2 steve steve 60 Jul 2 15:04 foo1 25373 0 -rw-rw-r-- 1 steve steve 0 Jul 2 15:04 foo1/index.html 27003 0 drwxrwxr-x 2 steve steve 60 Jul 2 15:04 foo2 25374 0 -rw-rw-r-- 1 steve ...


4

You can't do this with cp alone, short f listing the files to copy. Making partial copies goes beyond cp's capabilities. Rsync is the obvious tool for the job and it's very widespread. If you only have POSIX tools, you can use pax. You can omit files by rewriting their path to an empty string. cd /home && pax -rw -pe ...



Top 50 recent answers are included