Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to get output showing what has been copied by cp. The only problem is how to do it when I cp many files at a time. For instance, cp ./sourceDir/* $destinationPath/.

share|improve this question
up vote 4 down vote accepted

Like Lawrence has mentioned, you can use

cp -v

to enable "verbose" mode, which displays the files you copy. Something else that might be useful is

cp -v > foo

which will output the list of files to a file called foo. This is useful if you're going to copy a lot of files and you want to be able to review the list later.

share|improve this answer

cp -v enables verbose mode which displays what's being copied.

share|improve this answer

Check if your system has the -v option to cp.

If it doesn't, you can make a loop to show the file names and copy them one by one. This is not completely straightforward if you want to keep track of whether some copies failed.

for x in ./sourceDir/*; do
  echo "$x -> $destinationPath/${x##*/}"
  cp "$x" "$destinationPath/" || err=1
return $err

Alternatively, you might use a tool with many options such as rsync.

rsync -av ./sourceDir/ "$destinationPath/"

Going in the other direction, you might find it enough to see the expansion of the wildcard.

echo "Copying files:" ./sourceDir/*
cp ./sourceDir/* "$destinationPath/"

Or you might print a trace of shell commands:

set -x
cp ./sourceDir/* $destinationPath/
share|improve this answer
+1 for suggesting what to do if the -v option is unavailable. – Davidson Chua Dec 4 '13 at 1:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.