cp

Moving a folder from Desktop to the server?

I have a folder in my Desktop. I want to copy it to my server in Terminal. I tried this unsuccessfully [~/bin]# cp -r /Users/Sam/Desktop/tig-0.14.1 ~/bin/ cp: cannot stat `/Users/Sam/Desktop/tig-0.14.1': No such file or directory [edit] I run the command in my server. The problem seems to be in the fact that "/Users/Sam/Desktop/tig-...

How can you recursively copy all of the *.foo files in src to target using cp and/or find?

cp -v -ur path/to/jsps/ /dest/path/ The above command copies all of the files that have been updated from the source directory to the destination, preserving the directory structure. What I can't figure out is how to copy only *.someExtention files. I know that you can use something like: find -f -name *.jsp -exec some awesome comman...

How do I move/copy a symlink to a different folder as a symlink under Solaris?

It is an odd behaviour seen only on Solaris that when I try to copy a symbolic link with the "cp -R -P" command to some other folder with a different name, it copies the entire directory/file it's pointing to. For example: link -> dir cp -R -P link folder/new_link ...

what's the option for cp to create a directory if not exists?

Here is what I tried but failed: [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 [root@file nutch-0.9]# besides,any way to make ">" work that way,say to create a directory when need? [root@file nutch-0.9]# echo test > /nosuchtest/hi.t...

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

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 /Use...

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

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. ...

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

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 th...

cp command within php resulted in a partial copy

I have a small PHP script I wrote to help me push changes from staging to production. I run both staging and prod on the same server so my script copies changes from staging folders to prod folder. This has been working fine until today when I had a few instances when files were only partially copied over resulting in some down time....

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

Linux: 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 ...

How to use cp from stdin?

Note: # cat /tmp/foo - regular file /lib/a.lib /lib/b.lib /lib/c.lib /lib/d.lib cat /tmp/foo | xargs cp /tmp/fred cp: target /lib/d.lib is not a directory ...

cronned "cp *.html" is omitting new files on OSX

I have a cronned "cp *.html" command that runs every minute on an OSX box. The source files are regenerated from a database and written to the source directory just fine. The cp command usually picks them up and refreshes the copies in /Library/WebServer/Documents (this is for a quick-and-dirty internal website that monitors one of our...

Why is my Bash script adding <feff> to the beginning of files?

Greetings, While I've gotten many answer off this site, this is my first question, and I'm kinda excited about it... :) I've written a script that cleans up .csv files, removing some bad commas and bad quotes (bad, means they break an in house program we use to transform these files) using sed: # remove all commas, and re-insert t...

Unix C code cp in system()

I have a C code.. i which I have following code for UNIX: l_iRet = system( "/bin/cp -p g_acOutputLogName g_acOutPutFilePath"); when I am running the binary generated..I am getting the following error: cp: cannot access g_acOutputLogName Can any one help me out? ...

Bash: for loop, copy, backup

Hey, not 100% sure what this error means. % for f in "*" ; do cp $f ../backup/backup$f ; done cp: ../backup/backup* not found The purpose is to copy all the files into a folder into a backup folder and rename the files to backup. ...

cpio VS tar and cp

I just learned that cpio has three modes: copy-out, copy-in and pass-through. I was wondering what are the advantages and disadvantages of cpio under copy-out and copy-in modes over tar. When is it better to use cpio and when to use tar? Similar question for cpio under pass-through mode versus cp. Thanks and regards! ...

Compare 2 directories and copy differences to directory 3

Hello - I have three directories. I would like to compare directory1 with directory2, then take those changes/new files and copy them over to directory3. Is there an easy way to do this, maybe by using linux diff and cp commands? I'm open to ideas. Thanks! Andrew ...

How to Ensure file copy integrity in Ubuntu

In Ubuntu if a file /A/largefile.foo is moved via 'cp' or 'mv' to /B/largefile.foo, how can I ensure that the entire file is written before attempting to move the file a second time to /C/largefile.foo? Case: 1. An remote automated Script X begins an rsync to destination folder A of a very large file. 2. A cron job on the local machin...

How to emulate cp and mv --parent on osx

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. ...

git-archive vs. cp

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 o...