10 Answers
10

Note: this method will lose the file's permissions and ownership. Files copied this way will have the same permissions as if you'd created them yourself and will belong to you.

In this example, pv basically just outputs the file to stdout*, which you redirect to a file using the > operator. Simultaniously, it prints information about the progress to the terminal when you do that.

There are three important streams of data in a unix-like system: stdout (standard output), stderr (standard error) and stdin (standard input). Every program has all three, so to speak. The pipe-operator redirects a programs output to another programs input. The > operator redirects a programs standard output to a file. cp basically does nothing fancier than

cat source > destination

(where cat just reads a file and prints it to stdout). pv is just like cat, but if you redirect it's output stream somewhere else, it will print progress information to stdout instead.

Take a look at man pv to learn more about it.

Another option, as DoR suggests in this answer, is to use rsync instead:

rsync -ah --progress source-file destination

This will preserve the files permissions/ownership while showing progress.

It may or may no be significant (depending on the situation), but pv does not handle permissions the same way as cp does... (based on one quick test I tried: pv didn't copy the execute bit across.. rsync did.
–
Peter.ODec 14 '10 at 15:55

If you're like me, and forget about pv, you can go snooping in /proc/PID of cp/fd and /proc/PID of cp/fdinfo to figure out progress. (It's up to you to infer speed.) I use this technique to watch updatedb.
–
ThanatosDec 26 '10 at 1:30

for a man of pv without installing it see here
–
Walter TrossNov 16 '12 at 13:45

If you want to see if your files are transferring correctly you could use gcp and gcp is like cp but by default gives you a progress bar so that you can see what is being copied. As the program's wiki notes, gcp has several useful features such as

transfer progression indication

continuous copying on error (skip to next file)

copy status logging: gcp logs all its actions so that it is possible to know which files have been successfully copied

However, even when the progress bar has reached 100% when using the tool, you must wait until your terminal prompt reappears before safely removing your media so that you can ensure that the transfer process has successfully finished.

gcp is used to copy files and has options such as --preserve so that various attributes and permissions can be preserved and --recursive so that whole directories can be copied. More information on its options can be found by entering man gcp or by going to the Ubuntu manpages online. A tutorial is also available on this site.

Install gcp from the repositories with

sudo apt-get install gcp

(Note: in Ubuntu 12.10 the new automount point is, for example, /media/user/usbdisk)

This works great in the current Ubuntu (14.10). It also supports the -r flag to recurse directories. It can even be aliased as a direct replacement for cp: alias cp="rsync -ah --progress"
–
rustyxDec 23 '14 at 21:04

Your idea made perfect sense to me. I am copying several files from an old CD-ROM and I just want to make sure it isn't stuck trying to read a corrupted file. Printing the files that have been successfully read solved my problem.
–
Lucio PaivaNov 21 '14 at 14:46

Just to throw my $0.02, what I usually do with trivial copying situations (i.e. no -R):

See how big the file is and remember

Start copying

Open another terminal

Run watch ls -lh DIR on the directory where the target is

This can keep me updated on target file size, with quite a minimum hassle.

As an alternative for less trivial situations, e.g. recursively copying directories, you can use watch du -hs DIR to see summary of DIR size. However du can take long to compute and can even slow down the copying, so you might want to use -n INTERVAL argument to watch so that trade-off is acceptable.

Update: In case you use wild-cards with command used with watch du, e.g. watch du -hs backup/*, don't forget to quote:

watch "du -hs backup/*"

otherwise the wild-cards will be expanded only once, when watch is started so du will not look at new files / subdirectories.