cp

How can I make a progress bar while copying a directory with cp?

六月ゝ 毕业季﹏ 提交于 2019-11-27 00:03:14
问题 I suppose I could compare the number of files in the source directory to the number of files in the target directory as cp progresses, or perhaps do it with folder size instead? I tried to find examples, but all bash progress bars seem to be written for copying single files. I want to copy a bunch of files (or a directory, if the former is not possible). 回答1: You can also use rsync instead of cp like this: rsync -Pa source destination Which will give you a progress bar and estimated time of

How to have the cp command create any necessary folders for copying a file to a destination [duplicate]

大兔子大兔子 提交于 2019-11-26 23:50:27
问题 This question already has answers here : Linux: copy and create destination dir if it does not exist (19 answers) Closed 4 years ago . When copying a file using cp to a folder that may or may not exist, how do I get cp to create the folder if necessary? Here is what I have tried: [root@file nutch-0.9]# cp -f urls-resume /nosuchdirectory/hi.txt cp: cannot create regular file `/nosuchdirectory/hi.txt': No such file or directory 回答1: To expand upon Christian's answer, the only reliable way to do

Copy all files with a certain extension from all subdirectories

我们两清 提交于 2019-11-26 17:34:48
问题 Under unix, I want to copy all files with a certain extension (all excel files) from all subdirectories to another directory. I have the following command: cp --parents `find -name \*.xls*` /target_directory/ The problems with this command are: It copies the directory structure as well, and I only want the files (so all files should end up in /target_directory/) It does not copy files with spaces in the filenames (which are quite a few) Any solutions for these problems? 回答1: --parents is

Linux: copy and create destination dir if it does not exist

橙三吉。 提交于 2019-11-26 15:42:27
I want a command (or probably an option to cp) that creates the destination directory if it does not exist. Example: cp -? file /path/to/copy/file/to/is/very/deep/there mkdir -p "$d" && cp file "$d" (there's no such option for cp ). Paul Whipp If both of the following are true: You are using the GNU version of cp (and not, for instance, the Mac version), and You are copying from some existing directory structure and you just need it recreated then you can do this with the --parents flag of cp . From the info page (viewable at http://www.gnu.org/software/coreutils/manual/html_node/cp-invocation

Linux: copy and create destination dir if it does not exist

喜夏-厌秋 提交于 2019-11-26 12:15:23
问题 I want a command (or probably an option to cp) that creates the destination directory if it does not exist. Example: cp -? file /path/to/copy/file/to/is/very/deep/there 回答1: mkdir -p "$d" && cp file "$d" (there's no such option for cp ). 回答2: If both of the following are true: You are using the GNU version of cp (and not, for instance, the Mac version), and You are copying from some existing directory structure and you just need it recreated then you can do this with the --parents flag of cp

How to move or copy files listed by 'find' command in unix?

一世执手 提交于 2019-11-26 12:06:52
问题 I have a list of certain files that I see using the command below, but how can I copy those files listed into another folder, say ~/test? find . -mtime 1 -exec du -hc {} + 回答1: Adding to Eric Jablow's answer, here is a possible solution (it worked for me - linux mint 14 /nadia) find /path/to/search/ -type f -name "glob-to-find-files" | xargs cp -t /target/path/ You can refer to "How can I use xargs to copy files that have spaces and quotes in their names?" as well. 回答2: Actually, you can

How to use 'cp' command to exclude a specific directory?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 10:04:16
问题 I want to copy all files in a directory except some files in a specific sub-directory. I have noticed that \'cp\' command didn\'t have a --exclude option. So, how can I achieve this? 回答1: rsync is fast and easy: rsync -av --progress sourcefolder /destinationfolder --exclude thefoldertoexclude You can use --exclude multiples times. rsync -av --progress sourcefolder /destinationfolder --exclude thefoldertoexclude --exclude anotherfoldertoexclude Note that the dir thefoldertoexclude after -