There’s a lots of information of how to use pv together with ”dialog” as a progress indicator for a lots of different projects. For example, even pv shows an example on how to show a progress bar for taring and gzipping a file archive. But there are almost no documents that describes a similar thing for a simple chown/chmod process. Probably, in normal cases, this is not being done since such process is fast enough to not needing it. But for larger directory structures it sometimes is nices with a progress bar, rather than the verbose output of the process.
So here’s how to do it!
#!/bin/sh directory="/home/myLargeHome" permissions="myuser:mygroup" # Run chown in verbose mode, but redirect the verbosity somewhere else, while pv counts the progress. # pv runs in line-mode instead of byte mode. chown -Rv $permissions $dir | \ pv -f -c -n -l -s $(find |wc -l) 2>&1 >/dev/null | \ dialog --gauge 'Taking ownership of $directory' 7 70 0
Adding for example ”-i 0.1” to pv will make dialog update the view more often, but it might affect the performance of the process.
The result will look like this: