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


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.


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


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/
  • +1 for suggesting what to do if the -v option is unavailable. – Davidson Chua Dec 4 '13 at 1:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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