All Questions

Tagged with
Filter by
Sorted by
Tagged with
1
vote
2answers
61 views

Copy the same file to the desktops of all users

I’m looking for a way to copy a file to all Desktops directory of each user. Something like: cp myfile /home/*/Desktop/ I found a way to copy files to all home directories using xargs but it fails ...
-1
votes
2answers
111 views

cp -a doesn't work to copy all files inside a directory

I desire to copy all files inside a directory which has only these files (all are regular files - there are no directories, symlinks, etc, inside that directory) to another pre-existing directory. The ...
-1
votes
2answers
142 views

How to copy files one by one to different folders?

In a directory I have files with the names: 01.txt 02.txt 03.txt In the same directory are folders with the names: 01.abc 02.def 03.ghi I need a command to copy the files to the folders one by one,...
0
votes
2answers
31 views

Copying diff results files

I have two folders - Folder A and Folder B. I compared the files from both folders using diff command. Now after finding that certain files are only available in Folder A and Certain files in Folder ...
0
votes
2answers
63 views

Copy every 10 files from source into a target directory using cp

I have 110 large files inside a directory. But I cannot copy them at once since the system gets timed out after 50 min. I want to copy files 1 to 10, next 11 to 20, next 21 to 30, and so on. The order ...
2
votes
1answer
1k views

“Cannot create directory … no such file or directory”

When executing the dockerfile, the command RUN cp -rf roundcubemail-1.2.3/. /var/www/html/ is executed and I'm getting the following error: cp: cannot create directory '/var/www/html/': No such file ...
0
votes
2answers
22 views

Copy specified subdirectories

I have a bunch of folders in an external HDD and I want to copy a part of them. The folders have the following structure: A001A A003A A004A etc... ...and all the folders contain similar directories ...
0
votes
2answers
65 views

How could I copy the same directory multiple times but with a different name?

I have a directory called 400K that has some files in it, I want to copy this directory multiple times but with different names. I want something like: cp -r 400K 500K 600K 700K I was considering ...
1
vote
3answers
2k views

copy the file and keep full path

I need to copy the file to destination folder with it's full path. I can do it on Linux (Red Hat/Centos) easily like this: cp --parents /some/path/to/file /newdir Then I get, in destination ...
1
vote
2answers
107 views

Compare existing file in two different directories, copy if not existent, else overwrite it

I'm trying to build a scrip that compare a file inside different 2 dir,then copy them from dir1 to dir2 is it's not exists in the dir2, or overwrite it if its already existed. I know that i can use ...
4
votes
3answers
19k views

How to copy directories via ssh

I am connected with ssh and I want to copy a directory from my local to our remote server; how can I do that? I have read several post using scp but that doesn't worked for me. Some posts suggested ...
-3
votes
1answer
59 views

How to create copies of a directory with sequential numbers

I have a template directory containing sub-directories and MS-Windows links. This directory needs to be sequentially reproduced at the same folder level. The range needs to be from one to twenty. So, ...
3
votes
3answers
2k views

Copying newer files only

I have a simple shell script. What i'd like to do, is copy the files in /home/imp/imp/msgs/ to /home/imp/imp/msgs/bak/, but only if they are newer in the source directory than the destination ...
1
vote
2answers
8k views

cp says “same file” for two different directories

I have directory A with subdirectory B and am trying to copy everything from B to A. Within A, I run cp -ar B/ ~/A, and get the message that "cp: âB/â and â/u/username/A/Bâ are the same file" ...
1
vote
0answers
58 views

Can cp -r replace the cp -a in this case?

If I understand correctly the option cp -a someDir is essentially to archive a dir i.e. to copy its contents/structure and preserve access time & access rights. And it differs with cp -r someDir ...
0
votes
2answers
4k views

Copying files from one sub directory to another

I think I must be missing something obvious. I am in a directory called AmHist, with 2 subdirectories, Assign and Resources. I want to move 2 files from Assign to Resources. I try cp LinuxHist ...
0
votes
1answer
41 views

Copy folders has specific part of name and it is content

I have a long list of folder as follow: 001_bat_3513 002_mon_3213 003_bat_3515 004_btt_3540 005_bat_4513 055_bpt_8523 056_bot_3513 058_bat_1513 . . From this list: How can I copy the folders ( and ...
-4
votes
1answer
2k views

how to move all files under one directory to home directory

I have the script files script1.ksh ...script10.ksh in the directory star2 PATH : home/aaa/star2 I need to move all the files under star2 to the home directory (home/aaa) NOTE : I do not want the ...
1
vote
1answer
591 views

Is it possible to overwrite a directory with a file in linux

Can someone please help me with a possible case of accidental deletion on a linux box? I ran the following command: cp file1 /newdir1/folder1 What I intended to do was to copy file1 to the pre-...
3
votes
3answers
23k views

Understanding permissions properly for cp [duplicate]

I am trying to understand the permission usage for the cp command in unix. What are the permissions required for copying a file into a directory What are the permissions required for copying out of a ...
4
votes
2answers
4k views

copy recursively skipping directories with specific name

I have a directory with ~100 Gb. I need to copy this directory to other place skipping specific folders (there is a lot of them). The following is a wrong code to demonstrate my needs. $ cp -r ~/...
1
vote
3answers
115 views

script for copying directories with particular increment

I have directories which are named as 0.1, 0.15,0.2, 0.25, 0.3,0.35 and so on. Now I want to copy directories at particular increments say of 0.1 together to a separate directory. Say directories 0.1,...
0
votes
1answer
50 views

Copying directories to directories with different names

How can I copy a number of directories: directory_01 directory_02 directory_03 to different directories tmp_directory_01 tmp_directory_02 tmp_directory_03 where each tmp_directory_* directory has ...
0
votes
1answer
1k views

Copying files containing specific text preserving directory structure

Using the code in this answer, I can easily copy a file containing specific text from one folder to another. With the -r option I can also search inside directories recursively. The result is that ...
2
votes
2answers
993 views

Copy certain files from specified subdirectories into a separate subdirectory

I want to copy all .fastq files from every subdirectory that ends in '_CSF' into another already created subdirectory, dir1_CSF. I understand how to copy certain files but not from certain ...
1
vote
2answers
601 views

May cp override subdirectories with the same name?

I downloaded an Adobe flash plugin, It includes a .so file and a directory called usr. In this folder, it has sub-folders like bin, lib, lib64, share. In the readme file, it says I need to do the ...
2
votes
2answers
156 views

How-to overwrite directory on multiple places with 1 source directory

So today I encountered one of my PHP files was outdated so I've got to overwrite the phpthumb directory on the entire server. Multiple websites use this folder on multiple unknown locations, so how ...
3
votes
1answer
641 views

Why does `cp -a . /dir` copy contents instead of directory?

I wanted to copy a directory that I was presently in. I tried cp -a . ~/xyz It copied the contents of the directory, yet this worked: cp -a "$(pwd)" ~/xyz [As desired, this copied the directory ...
2
votes
3answers
544 views

copying parallel directories Why does cp -r work this way?

The following works correctly (ie does what I want) cd /var/www/release/ mkdir wiki cp -rp ../html/wiki ./ However if I do (what seems more intuitive) cp -r ../html/wiki ./wiki it will create /...
1
vote
1answer
2k views

Is there a way of copying only directories and not files? [closed]

I want to copy only directories from a folder on a remote server to my server. Is that possible? Here is the code I have so far but it copies files and folders: scp -rq username@192.168.78.331:/copy/...
1
vote
2answers
646 views

moving files of certain formats from subdirectoris to directories with same folder names

I’ve got a weird situation. I have 100s of folders with flac and mp3 copies of the same tracks. I need to separate the mp3s from the flacs and put them into similarly named directories. for example: ...
4
votes
1answer
503 views

Confusion on the cp command when creating a new directory

Let me explain my problem with a simpler scenario. We have these two directories: ~/Foo and ~/Bar. Foo contains the files test1.txt and test2.txt. If I run the command cp -R Foo Bar, the Bar directory ...
8
votes
3answers
20k views

cp --no-target-directory explained

Question: I need a simple example of how to use cp --no-target-directory. I do experience some difficulties in understanding cp --no-target-directory. I do understand the explanation for mv --no-...
3
votes
3answers
1k views

Merging two directory without copying the files

Let's say I have as follows : Folder A C1 file a A2 Folder B C1 B2 file b B3 What I want is to merge these two folders, which would give me : Folder C ...
6
votes
2answers
28k views

copying files from one directory to another

I have to copy a set of files from one folder to another folder and I'm using the following command: cp -rf `head -n 100 /home/tmp/abc.txt` /home/tmp/test/files the file contents in abc.txt is like: ...
2
votes
1answer
534 views

How can I make multiple copies of one folder without merging?

When two or more identically named folders are to be copied into or moved to the same location, the default option either in the GUI file manager, or using in a terminal cp -r --backup=numbered or ...
4
votes
5answers
11k views

Find and copy directories containing file type

I have a directory "Movies" containing subdirectories "Movie Name". Each subdirectory "Movie Name" contains a movie file and related image/nfo files etc. I'm trying to copy all directories containing ...
31
votes
3answers
67k views

Better way to copy multiple directories to new directory

Is there a better way on the command line to essentially accomplish the following but with a single command cp -r css/ ar/ cp -r images/ ar/ cp -r js/ ar/ cp -r backups/ ar/ I've just been stringing ...
2
votes
2answers
4k views

Can one copy a relpath in one command?

I find myself doing this often enough that I wonder if there's a standard Unix way to do it: % mkdir -p /TARGETDIR/relative/path/to % cp ./relative/path/to/somefile /TARGETDIR/relative/path/to In ...
0
votes
1answer
2k views

How to copy a folder from remote machine to my system using ssh or any other way

Hi I need to copy a folder of size 885 MB from a remote machine to my system using ssh and port no is 1500 What is the command I can use to accomplish this path of remote folder is /u001/app/...
12
votes
6answers
15k views

progress information via pv for directory copy

I need to copy a very large directory (talking in terabytes here) and want to monitor the progress. I found that pv is a nice utility, but how can I use it for copying directories recursively? (pv ...
69
votes
6answers
36k views

Flattening a nested directory

This is probably very simple, but I can't figure it out. I have a directory structure like this (dir2 is inside dir1): /dir1 /dir2 | --- file1 | --- file2 What is ...
2
votes
2answers
537 views

cp file device:directory on Minix

In my operating systems class we had to modify the boot screen of the Minix OS. I understood just about everything we did, but at the end of the make for compiling the new OS, there's a line: cp ...
58
votes
3answers
70k views

Why unix mv program doesn't need -R (recursive) option for directories but cp does need it?

I always get messed up when need to use cp or mv: "do I need -R option when working with dir?" In GNU coreutils cp does need -R and mv doesn't. I just can not find any reason why cp needs -R option ...
3
votes
6answers
2k views

Make directory copies using find

I have a directory with a bunch of subdirectories in it. Thus /usr/local/src/ccl/ccl-1.8/x86-headers$ ls elf gl gmp gnome2 gtk2 jni libc Each of these directories has a further subdirectory C ...
4
votes
3answers
4k views

How can I selectively copy files from one directory to another directory?

On Linux, how do I selectively copy most – but not all – files from a directory (dir1) to another directory (dir2)? I do not want to copy *.c and *.txt files to dir2. The cp man page ...
5
votes
3answers
2k views

Delete files in a directory which are also in another directory

I copied a directory using this: cp -r dir/ ../../ without thinking and realized that it copied the contents of dir instead of actually dir to the above directory. Now I have a mess of files I need ...
3
votes
1answer
7k views

Why can I not copy a direcotry from *nix to a mounted smbfs share on Windows 7?

I've mounted a Windows 7 directory on my FreeBSD box via smbfs: mount ... //ROOT@BARYONYX/GVKV on /usr/home/gvkv/win (smbfs) but for some reason when I try to copy a directory: cp .vim /win I get ...