cp

C++ Copy directory recursive under unix

余生颓废 提交于 2019-12-12 14:10:54
问题 There are no any examples of the functions ready for use on c++ without additional libs to Copy recursive files and folders to the new location. Some alternative to system("cp -R -f dir"); call. I'm only found this Recursive directory copying in C example on the thread answer, but its not ready for use and I'm not sure that this example is correct to start with. Maybe somebody have working example on the disk? 回答1: Here is a complete running example for recursive copying with POSIX and

Unable to copy all but ~ -files and .gitconfig to Git -repo

孤街浪徒 提交于 2019-12-11 16:38:30
问题 I have my dev files at ~/bin/, while my Git repo files at ~/github/myProject/. I always run the following file to copy files from the former location to the latter one: #!/bin/zsh # editors# {{{ cp /Users/Masi/.emacs /Users/Masi/gitHub/MasiDvorak/ cp /Users/Masi/bin/editors/emacs/* /Users/Masi/gitHub/MasiDvorak/editors/emacs/ cp /Users/Masi/.vimrc /Users/Masi/gitHub/MasiDvorak/ cp /Users/Masi/bin/editors/vim/* /Users/Masi/gitHub/MasiDvorak/editors/vim/ # }}} # shells# {{{ cp /Users/Masi/

_cp_dispatch not getting called in cherrypy

泄露秘密 提交于 2019-12-10 19:46:36
问题 In the following example, I would expect to get an exception when accessing url http://127.0.0.1:8080/b/method_b. Instead, I get normal http response containing text 'method_b' in browser. No exception raised, meaning that _cp_dispatcher is not called. Am I getting something wrong about _cp_dispatch? I am using cherrypy version 3.8.0 in python 2.7.10 import cherrypy class B(object): def _cp_dispatch(self, vpath): raise Exception("Here!!") @cherrypy.expose def method_b(self): return "method_b"

Using gzip to compress files to transfer with aws command

拜拜、爱过 提交于 2019-12-10 17:13:29
问题 $ 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? 回答1: $ 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

To copy files each minute at /var/www without sudo

雨燕双飞 提交于 2019-12-08 10:17:45
问题 How can you copy a folder to /var/www without sudo? My folder codes has the following permissions at /var/www 4 drwxr-xr-x 8 root root 4096 2009-08-09 03:01 codes I can only sudo cp -r ~/Dropbox/codes/ /var/www to copy the files. I cannot copy them without sudo. 回答1: Owning /var/www yourself might conflict with other options on your system. On my Debian system I would do this sudo addgroup www sudo adduser nr www # add myself to the www group sudo chgrp -R www /var/www # make files in the

run cp command to make a copy of a file or change a file name in Python

心不动则不痛 提交于 2019-12-08 02:14:34
问题 In python 2.7.2, i need to make a copy of a file in Linux. newfile = "namePart1" + dictionary[key] + "namePart2" os.system("cp cfn5e10_1.lp newfile") But, the newfile cannot be replaced by its correct string. the posts in the forum cannot help. Any help is really appreciated. 回答1: Use shutil.copyfile to copy a file instead of os.sytem , it doesn't need to create a new process and it will automatically handle filenames with unusual characters in them, e.g. spaces -- os.system just passes the

How to emulate cp and mv --parent on osx

独自空忆成欢 提交于 2019-12-07 05:24:09
问题 Osx mv and cp does not have the --parents option, so how does one emulate it ? I.e. mv x/y/a.txt s/x/y/a.txt when s is empty gives a no directory found error unless one does a mkdir first which is rather cumbersome when trying to do this did thousands of files. 回答1: The solution (which works on all platforms that has an rsync) is: Use find or some other tool to create a file with the files you want moved/copied, i.e. find *.mp3 > files.txt Then use rsync files-from to specify it and by using

BASH: Copy all files and directories into another directory in the same parent directory

断了今生、忘了曾经 提交于 2019-12-06 13:26:30
问题 I'm trying to make a simple script that copies all of my $HOME into another folder in $HOME called Backup/ . This includes all hidden files and folders, and excludes Backup/ itself. What I have right now for the copying part is the following: shopt -s dotglob for file in $HOME/* do cp -r $file $HOME/Backup/ done Bash tells me that it cannot copy Backup/ into itself. However, when I check the contents of $HOME/Backup/ I see that $HOME/Backup/Backup/ exists. The copy of Backup/ in itself is

run cp command to make a copy of a file or change a file name in Python

久未见 提交于 2019-12-06 12:45:26
In python 2.7.2, i need to make a copy of a file in Linux. newfile = "namePart1" + dictionary[key] + "namePart2" os.system("cp cfn5e10_1.lp newfile") But, the newfile cannot be replaced by its correct string. the posts in the forum cannot help. Any help is really appreciated. Use shutil.copyfile to copy a file instead of os.sytem , it doesn't need to create a new process and it will automatically handle filenames with unusual characters in them, e.g. spaces -- os.system just passes the command to the shell, and the shell might break up filenames that have spaces in them, among other possible

Linux/Cygwin recursively copy file change extension [closed]

余生长醉 提交于 2019-12-06 09:58:34
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I'm looking for a way to recursively find files with extension X ( .js) and make a copy of the file in the same directory with extension Y ( .ts). e.g. /foo/bar/foobar.js --> /foo/bar/foobar.js and /foo/bar/foobar.ts /foo/bar.js --> /foo/bar.js and /foo/bar.ts etc etc My due diligence: I was thinking of using