cp

Copy or rsync command

99封情书 提交于 2019-12-02 15:20:11
The following command is working as expected... cp -ur /home/abc/* /mnt/windowsabc/ Does rsync has any advantage over it? Is there a better way to keep to backup folder in sync every 24 hours? Rsync is better since it will only copy only the updated parts of the updated file, instead of the whole file. It also uses compression and encryption if you want. Check out this tutorial . rsync is not necessarily more efficient, due to the more detailed inventory of files and blocks it performs. The algorithm is fantastic at what it does, but you need to understand your problem to know if it is really

grep file for string and copy directory to another directory

六眼飞鱼酱① 提交于 2019-12-02 07:07:51
I have large number of directories with just one file -- index.html -- in each directory. I would want to use grep to look for pattern in file and then copy the directory along with the file to another directory. Example for copying files, I have seen, but I would want to copy the directory with the file in to another directory. so say following are the list of matching files with directory using grep -rl "string" source_dir d1/index.htmk d2/index.html d3/index.html ... ... a long list. Now would want to copy to dest-dir so dest_dir looks like . .. d1/index.html d2/index.html d3/index.html ...

How do I use a variable containing a filename with spaces in a bash script?

≯℡__Kan透↙ 提交于 2019-12-02 04:43:06
问题 I have a simple bash script running on OS X that removes specific files and directories and copies new ones in their place. One Mac .app directory contains a space, and when I run the script there is a "No such file or directory" error. Here is the relevant code. A good amount has been cut out, so simply hard coding these differently isn't possible (the variables must be broken up as they are): CP="cp -Rf" INSTALL_DIR="/Applications/" APP="The App.app" NEWAPP="$HOME/Downloads/The App.app" $CP

git-archive vs. cp

南笙酒味 提交于 2019-12-02 02:17:29
问题 What is the advantage of using git archive master/foo | tar -x -C ~/destination to deploy a copy of /foo vs. just copying from the the working copy with cp foo ~/destination/foo So, unless for some reason you don't want to copy everything over from that sub directory foo in master (or whatever branch you happening to be working on), using cp for deploying to a [destination] would suffice. 回答1: git archive only exports items that are part of the git repository. cp copies everything that's

git-archive vs. cp

Deadly 提交于 2019-12-01 22:10:45
What is the advantage of using git archive master/foo | tar -x -C ~/destination to deploy a copy of /foo vs. just copying from the the working copy with cp foo ~/destination/foo So, unless for some reason you don't want to copy everything over from that sub directory foo in master (or whatever branch you happening to be working on), using cp for deploying to a [destination] would suffice. git archive only exports items that are part of the git repository. cp copies everything that's under the specified directory, including the .git directory, files which are ignored by git, etc. 来源: https:/

Using gzip to compress files to transfer with aws command

好久不见. 提交于 2019-12-01 19:51:21
$ gzip file.txt | aws s3 cp file.txt.gz s3://my_bucket/ I am trying to gzip file.txt to file.txt.gz and the passing it to aws program which has s3 as a command and cp as a subcommand. Generates : warning: Skipping file file.txt.gz. File does not exist. I'm newbie in linux. Can anyone help on this please? $ gzip -c file.txt | aws s3 cp - s3://my_bucket/file.txt.gz Unless you desire to have a .gz locally of file.txt, this allows you to accomplish the gzip and transfer in one step, leaving file.txt in tact. Newer versions of the AWS CLI now allow you to steam, UNIX style, via '-' character.

How to copy files found with grep

删除回忆录丶 提交于 2019-12-01 19:33:29
I am running this command to find all my files that contain (with help of regex)"someStrings" in a tree directory. grep -lir '^beginString' ./ -exec cp -r {} /home/user/DestinationFolder \; It found files like this: FOLDER a.txt -->SUBFOLDER a.txt ---->SUBFOLDER a.txt I want to copy all files and folder, with the same schema, to the destination folder, but i don't know how to do it. It's important copy files and folder, because several files found has the same name and I need to keep it. Try this: find . -type f -exec grep -q '^beginString' {} \; -exec cp -t /home/user/DestinationFolder {} +

Shell Scripting unwanted '?' character at the end of file name

。_饼干妹妹 提交于 2019-11-30 19:58:14
I get an unwanted '?' at the end of my file name while doing this: emplid=$(grep -a "Student ID" "$i".txt | sed 's/(Student ID: //g' | sed 's/)Tj//g' ) #gets emplid by doing a grep from some text file echo "$emplid" #prints employee id correctly cp "$i" "$emplid".pdf #getting an extra '?' character after emplid and before .pdf i.e instead of getting the file name like 123456.pdf , I get 123456?.pdf . Why is this happening if the echo prints correctly? How can I remove trailing question mark characters ? It sounds like your script file has DOS-style line endings (\r\n) instead of unix-style

How to resolve /var/www copy/write permission denied?

怎甘沉沦 提交于 2019-11-30 13:00:23
问题 I am a newbie in php, mysql. I have written a hello.php script, which I am trying to copy into /var/www directory (and will later want to open it through web browser). The problem with the same is that I am not allowed to save/write any files in /var/www despite me being the root. I tried implementing steps in this question, but I get the following error when I process the third line find /var/www/ -type f -exec chmod g+w '{}' ';' chmod: changing permissions of `/var/www/index.html':

Copy every file of entire directory structure into base path of another

天大地大妈咪最大 提交于 2019-11-30 11:56:56
问题 I have a directory-tree with a lot of files in it. I'd like to copy all of those files into one new directory, but with all files located in the base of the folder. So I have something like this: images ├── avatar.png ├── bg.jpg ├── checkbox.png ├── cross.png ├── datatables │ ├── back_disabled.png │ ├── back_enabled.png │ ├── forward_disabled.png │ ├── forward_enabled.png │ ├── sort_asc.png │ ├── sort_asc_disabled.png │ ├── sort_both.png │ ├── sort_desc.png │ └── sort_desc_disabled.png ├──