Questions tagged [cp]

Questions relating to the Linux 'cp' command.

Filter by
Sorted by
Tagged with
0
votes
0answers
12 views

Issue when copying to SD cards

When I copy to SD cards with cp, sometimes copied content disappears after unmounting/mounting or other devices have problems reading the files. BUT, if I copy with the UI it works fine. Any idea why? ...
0
votes
2answers
57 views

Way to speed up cp -a (using cp -a within a thumb drive is very slow)

When using a thumb drive with a persistent operating system, it happens that the persistent partition casper-rw gets corrupted, if one pulls out the thumb drive too early after shutting down the ...
1
vote
2answers
45 views

Move all JPGs and rename them into one directory

.Hi. I have a bunch of jpgs in 100s of subfolders , I know I can move them all with this command find -type f -iname "*.jpg" -exec mv -av {} /home/root/private/pics/ \; But my all my jpgs ...
0
votes
0answers
46 views

cp: cannot stat '{1..112046}.pth': No such file or directory

I am using Ubuntu 16.04. I am trying to copy the range of files from one directory to another directory. cp {1..112046}.pth path/to/destination_folder While being inside the source folder. But it ...
0
votes
0answers
13 views

How to scp single files from multiple subdirectories into corresponding subdirectories

I’m fairly new to ubuntu and have come across a (probably) simple stumbling block. I have a main dir with named subdirectories that all contain multiple files. In each of these subdirectories I have ...
2
votes
1answer
127 views

cp .* /home/name erased all files in /home/name

A while ago, I got a new ssd for my laptop, so I dd'd everything onto the new drive, and used it for a while without issue. I decided to put the old drive back into my laptop, and put newer ssd into a ...
1
vote
0answers
68 views

Problems copying to SD card

I am trying to automate copying a large file (25MB +) to an SD card, but it's not working - So I've tried in the command line... cp /tmp/MIRROR/myfile.db /run/media/mmcblk0p1/MIRROR/ but this throws ...
0
votes
1answer
73 views

Stop `cp -al` trying to link to hidden files?

I would like to make a "hard-links" copy of my home directory before syncing my home directory with another computer with unison, just in case unison goes awry. But cp -al tries to link to ...
1
vote
1answer
59 views

why doesnt this bash script get all the files?

I have a large folder with subfolders of pdf files. I want to get all the pdf files (290 of them) and get them into one directory. (I thought that would be simple.) so that I can concatenate them into ...
-3
votes
1answer
62 views

How can I copy a file n Linux terminal, without pasting it? [closed]

I have run this in my Linux machine # cp file . Is that command copying file1? Is there anyway to paste file1 in other folder after using above command (whitout cp file1 path/to/file)?
9
votes
2answers
941 views

cp recursive with specific file extension

I am trying to copy all .odt files including those in subdirectories. cp -r ~/Documents/* ~/copies # works as expected cp -r ~/Documents/*.odt ~/copies # does not work as expected The first line ...
0
votes
2answers
109 views

Copy files and set owner/group to the owner/group of the destination directory

I have a script used in different environments. This scripts uses sudo cp to copy files (sudo otherwise it has no access). But sudo cp creates the files with the wrong owner. It cannot keep the owner ...
0
votes
1answer
525 views

sudo: unknown uid 1000: who are you? (sudo completely broken)

I am new to Linux environment and I need little guidance. I made a mistake while setting up the password and username of mosquito MQTT broker on AWS ubuntu 18.04 instance. I have altered the contents ...
0
votes
0answers
24 views

Is there a command could be used to copy everything in a directory? [duplicate]

I have 2 files and 1 directory in /home/ubuntu1 /home/ubuntu1 ├── code.py ├── code.pyc └── templates └── index.html I'm trying to copy all of them to /home/ubuntu2 I've tried cp *.*, which is to ...
1
vote
2answers
112 views

How to copy files with certain permissions to directory

I'm trying to make a copy of files with read and write permissions for the owner only, and then redirect that file to a directory named $dirA. I tried to use this command: cp (ls -l ~| grep -type f-...
0
votes
1answer
105 views

What is cp command with tilde in final part of destination? [duplicate]

For example: sudo cp /etc/apt/sources.list /etc/apt/sources.list~ With this command I not see any changes. What does the final tilde do?
0
votes
0answers
52 views

mv or cp all but one file/directory [duplicate]

I often use mv ./* DEST or cp -r ./* DEST to move/copy all files and directories from the current directory to another. But what if I want to move/copy all but one file/directory?
0
votes
0answers
24 views

TAB does't work properly with `cp` command when using environment variables [duplicate]

Question When using cp command with environment variables, why pressing TAB for auto-complete doesn't work properly? Description I have a directory $HOME/Music; I want to copy a file from within this ...
0
votes
1answer
398 views

Copying a .bashrc file from one user's directory to another

I am trying to copy a bashrc file from one folder to another. For example, the bashrc file is in Data/user/user1 and I am trying to copy it to Data/user/user2 with the following cp command: cp Data/...
1
vote
2answers
108 views

Need help using the SCP command line

I have a server with Ubuntu 18.04 I want to transfer my website to a new server. Here are my questions : How to copy files with png extension ? I tried the following command line but it doesn't work : ...
1
vote
1answer
77 views

File has weird name, and cannot be found after being copied

Technically all I'm trying to do is substitute one file with another using a script: echo "PASSWORD" | sudo -S rm paper_RPG.jar cp /home/network/PaperAndWaterfallUpdater/paper.jar paper_RPG....
0
votes
0answers
616 views

copy file to current directory [duplicate]

sample_dir |-- cambridge | |-- library | `-- security | |-- annex | `-- parking |-- faculty |-- history.online |-- markham | `-- annex |-- oxford | |-- outline.doc | `-- ...
0
votes
0answers
803 views

mv: missing destination file operand when special characters are involved [duplicate]

This one's silly. I saved my vim session with :Obsess -S Session.vim instead of :Obsess Session.vim, so now I have a -S/ Session.vim file in my project and can't open it with vim as the following is ...
0
votes
1answer
31 views

simple cp command problem “ i try to copy only ”

cp: 'test.txt' and 'test.txt' are the same file asadzoot@asadzoot-Vostro-14-3468:~/cnc/q1$ cp test.txt home/asadzoot/cnc/q1/ cp: cannot create regular file 'home/asadzoot/cnc/q1/': No such file or ...
0
votes
1answer
6k views

Copy all files from one folder to another in linux

I want to copy only files not folders from one folder to another in linux. I am using the following command cp sourceDir/* destDir The above command does copy all files to destDir but the command ...
0
votes
2answers
56 views

Copying a list of test/path/to/files to list of prod/path/to/files

I would like to copy a list of files in the form test/path/to/file/filename.xyz to their corresponding production path prod/path/to/file/filename.xyz. If the test path and the prod path are the same ...
2
votes
3answers
287 views

How to copy 12GB file from Ubuntu 19.10 to Android if My RAM size is 8GB

I tried different options to copy a 12GB movie from Ubuntu to Android (connected as a Camera for reliable connection, with mtp situation even worse), but surprisingly for me there is a RAM+SWAP ...
0
votes
1answer
125 views

simple question cp (command) [duplicate]

my problem is ''cp'' command I can't understand why I can't copy a simple text file for example: I have on the desktop two files "fis1" and "fis2" and in "fis1" I have "perfect" (text file) and I ...
5
votes
2answers
2k views

sh alternative to bash cp {file,file}

In a script, if I put #!/bin/bash at the top, this will work fine: cp directory/{foo,bar} destination However, with sh, this will give the error 'no such file or directory'. In sh, is there another ...
2
votes
3answers
558 views

Copy over a large number of files with new names

I have a large number of files (tens of thousands) I need to copy over from /dir1 to /dir2 but the name of the file must change as such: OLD NAME ---> NEW NAME filename.txt ---> bob_filename_1253....
-1
votes
1answer
342 views

script to copy multiple files from multiple directories to one of the folder/directory

I'm having five different directories in the home path which contain some files in all directories, as shown below. home/dir1 contains: abc121219.txt kucj.txt gtuj120518.txt gdkmcg.txt such.txt ...
0
votes
1answer
169 views

Copy all files from subdirectories and subsubdirectories to main directory with modifying file names by adding prefix of all parent directories

Following these two posts: Move files to parent directory, prefixing file name with former subdirectory name recursively add directory name to file name I would like to do the same but with copying ...
4
votes
3answers
7k views

How can I copy the contents of a child folder to its parent folder using command line?

I have this directory structure: parent_folder/child_folder/ I want to copy the contents of the child folder to the parent folder, but I don't know how to do it with cp.
-2
votes
1answer
70 views

Copy files such that individual files gets copied to the folder having file name as a string within complete folder name [closed]

I am using Cygwin as Linux shell, I have following contents in my current working directory: Files : Abc.dat 123.dat 456.dat Directories: W_Abc_w W_123_w W_456_w Now I want to copy files as ...
2
votes
3answers
2k views

trying to CP a directory to /dev/null

What I'm really tring to do, it verify the the data on an external drive is still readable. I thought the simplest and surest way to do this would be to copy everything to /dev/null. It works great ...
1
vote
0answers
768 views

Does copying files from EXT4 filesystem to NTFS lose permissions?

I recently attempted to back up my /home/user directory while removing ecryptfs from my system. I didn't have enough space on my Ubuntu EXT4 SSD so, not thinking, I used sudo cp -rp /home/user /media/...
0
votes
0answers
38 views

How to copy some lines from old folder after using ls to new blank file [duplicate]

My old folder has this output when I ls -lh drwxr-xr-x 2 ahmet sistem 4,0K Eyl 17 22:33 ahmet drwxr-xr-x 2 ali sistem 4,0K Eyl 20 16:08 ali drwxrwxr-x 2 hexcake hexcake 4,0K Eyl 13 18:57 ...
0
votes
1answer
81 views

How to copy files from a certain range into another directory from terminal?

I want to copy files 50,000 to 100,000 into a separate directory and I'm not sure how to go about doing this. For more context, I want to create a smaller dataset of images (50,000) from a larger ...
1
vote
2answers
229 views

How to replace cp command with wget?

I am very newbie to linux and its commands. What I want is use cp command instead of wget to request from browser. Because I'm using docker and the mongo site filtered our country's IP. I have ...
6
votes
1answer
3k views

How can I copy a directory without copying a specific file or subdirectory in terminal?

I have a directory main_dir which contains lots of files and 3 subdirectories (dir1 and dir2 and dir3). I want to copy it to another location without copying dir2 in one command. I searched the cp ...
1
vote
1answer
1k views

how to include wildcard characters in cp command

I want to use cp command in a script where the path structure has variable folder name. For example: folder structure: Workspace/unzipped_workspace/artifactory/my_folder123243/files Here ...
1
vote
1answer
202 views

Copying or rsyncing only files from subdirectories

I have a folder which is named Music. This folder contains the three subfolders Jazz, Rock and Folk. Now each of these three subfolders contains various .mp3 files. Now I want to copy the .mp3 files ...
0
votes
2answers
511 views

cp -r not copying all files from networked drive

I have an unusual problem, which is possibly down to me being a novice command line user, but also applies to using the GUI. The situation is that I have a networked drive mounted at /media/drive/dir ...
4
votes
2answers
421 views

Copying directories in linux only if it contains the specified file

I need to make a copy of all the folders under /parent (into a new location) but only if it has 123.dat - in which case I need to copy the folder too, but none of the other files it contains. So that ...
2
votes
0answers
270 views

cp -l instead of cp -s does not work?

I have a folder symlink to core files and a folder with my improvements like this: core/ -> /some/distant/root/directory/core/ script_a.py special/script_b.py special/script_c.py core-improvements/ ...
13
votes
8answers
6k views

Copy group of files (Filename*) to backup (Filename*.bak)

Background In Linux you can: List a group of files with ls Filename* Remove a group of files with rm Filename* Move a group of files with mv Filename* /New/Directory But you cannot copy a group of ...
0
votes
1answer
525 views

Insert value from JSON file into filename path

I need to copy a file and rename it based on a value from a json file: info.json { "folderName": "berlin" } to get the folderName from json I can use: jq '.folderName' info.json to copy the file ...
3
votes
1answer
368 views

Accidently removed very important file of my project using command “cp” [duplicate]

Very long story short. In essence this is the problem. I had some of my project files (new.cc) which I was working on for quite sometime. I created one backup of these files two months ago (old.cc), ...
0
votes
0answers
47 views

Using my backup disk

I have made an Ubuntu backup using a 3.5' internal HDD hooked up to a SATA-USB adapter with power supply, and I formatted it to FAT. I can't seem to transfer normal files onto it, as when I try to ...
0
votes
2answers
2k views

cp: cannot create directory '/home/rexxi/usr/lib/firefox-addons/plugins': No such file or directory

I tried to move files from downloads dir cp -r ~/Downloads/flash_player_npapi_linux.x86_64 ~/usr/lib/firefox-addons/plugins And I got a error message cp: cannot create directory '/home/rexxi/usr/...