Bash – Read all files in folder and subfolders – progress and size

bashbenchmarkfilesrecursiveshell-script

Command I have is:

time find . -type f -print -exec cp {} /dev/null \;

This command finds all files in current folder and subfolders, print the name of each file and copy each of them to /dev/null. At the end it shows how much time it took to copy all the files.

What I need is to count (show) all copied bytes at the end (so I would be able to compute the read speed //cache doesn't matter//) and/or show each file's size beside it's name.

If there would be possibility to show progress for each file (pv) – that would be great!

For this purpose I'm using Cygwin and it's bash shell, but script should also work on real Linux systems.

EDIT: The idea is to read the files, not to copy them (rsync).

Best Answer

Not sure I understand your question fully, but what about:

find . -type f -exec pv -N {} {} \; > /dev/null

Gives an output like:

  ./file1:  575kB 0:00:00 [1.71GB/s] [=======================>] 100%
  ./file2: 15.2GB 0:00:07 [2.22GB/s] [==>                      ] 15% ETA 0:00:38
Related Question