Questions tagged [cp]

cp is a UNIX command used to copy a file

Description

cp copies SOURCE to the destination DEST, or multiple SOURCE(s) to directory DIRECTORY.

Syntax

cp [OPTION]... [-T] SOURCE DEST

cp [OPTION]... SOURCE... DIRECTORY

cp [OPTION]... -t DIRECTORY SOURCE...

Related commands

824 questions
-2
votes
1 answer

how copy_file function is implemented which is used in CP command

I am looking at the implementation of copy command from the link : http://src.gnu-darwin.org/src/bin/cp/cp.c.html And its using copy_file function at its core. if (copy_file(curr, dne)) badcp = rval = 1; Can someone tell me how copy_file is…
kiran bobbu
  • 133
  • 2
  • 11
-2
votes
2 answers

simple cp $file1 $file2 script not working?

I tried searching for this question but I couldn't find a thread specifically like this one. I am trying to do a practice script where you enter in a source and a destination and the program copies the files for you. ./testscript "name of file to…
-2
votes
1 answer

Copying files between two Unix hosts

I am running a remote ssh server from my jailbroken iPod, and once connected I have root access to its file system, however when I try to copy files from the iPod to my computer, I realize I cannot access my computer's file system in that Unix user.…
JeffM
  • 105
  • 2
-3
votes
1 answer

Copy a file from a Docker to another Docker and execute it

As I mentioned above, I want to copy an executable file from a docker to another docker and run it. docker cp target/demo.jar test:/demo.jar is not working since docker cp can copy only "docker to host" or "host to docker". as a next step, I need…
RDD
  • 145
  • 1
  • 18
-3
votes
2 answers

Why I'm getting TLE even if I'm using memoization?

Here is the question statement Given two strings s1 and s2, return the length of their longest common subsequence. A subsequence of a string is a new string generated from the original string with some characters(can be none) deleted without…
-3
votes
1 answer

How to copy files with filenames that partially match a list strings in a text file?

For example, filenames.csv contains a list of product codes PROD111, PROD222, ... that partially match file names in a folder: PROD111a.jpg, PROD111b.jpg, ... How would i copy the files that match into a new folder?
Mark Webb
  • 9
  • 3
-3
votes
1 answer

How parsing works for unix commands: "rm" and "cp"

We are executing below commands rm -f $folder_name/filename* cp $folder_name1/filename1* $folder_name/ After checking the execution log we get following command executions rm -f '/home/user/file*' cp /home1/user1/file1* /home/user/ Why rm…
Kamlesh Khollam
  • 111
  • 2
  • 15
-3
votes
2 answers

Shell : What does this script do?

#!/bin/bash if test $# -ne 2 then echo "Error : Invalid number of arguments" else if [ -d $1 ] then if [[ $2 =~ ^[0-9]+$ ]] then ls -l $1 | while read line do eval "echo $line | cut -d' ' -f5" | while read ln …
Alba
  • 5
  • 4
-3
votes
3 answers

Linux - Find command and tar command Failure

I am using a combination of find and copy command in my backup script. it is used on a fairly huge amount of data, first, out of 25 files it needs to find all the files older than 60 mins then copy these files to a temp directory - each of these…
Vasanth Nag K V
  • 4,860
  • 5
  • 24
  • 48
-4
votes
1 answer

Building a version of the Linux cp command

Hi so im trying to build a version of the linux cp command in C,that can handle the following test cases cpy f1 f2 - copies content of f1 to f2 cpy f d - copies f to d/f cpy d1/d2/d3/f1 f2 -…
Kimeru
  • 21
  • 1
  • 3
-4
votes
1 answer

Difference between cp and cp -p -i

I am using cp command in my program to make a copy of a text file. But when I use -p -i with cp I don't understand the difference between the both. What's the difference between using simple cp and using options -p -i with it? Here is my line…
-6
votes
0 answers

Alex and his Array

Can someone give solution to this? I tried but somehow unable to get correct answer Meet Alex, a bright student who is dealing with an array challenge today. He has been given an array a1, a2, ..., aN of length N. The intriguing aspect of this…
-6
votes
1 answer

C program with functionality as cp command

I created this program that should copy a file, just as the cp command does in UNIX, except my code copies without arguments. I've went over my program multiple times, and cannot figure out the problem. It compiles without error, and runs without…
user2917900
  • 29
  • 1
  • 1
  • 7
1 2 3
54
55