I have a filenotfound
script as follows:
# Check if filenames listed in a text file exist.
while read -r || [[ -n $REPLY ]]; do
# Check if file (local or with full path) exists.
[[ -f $REPLY ]] && continue
# Filename with some wrong path.
... "long" processing (try to find file elsewhere, with same name)...
done
which I use in the following manner:
cat list-of-files.txt | filenotfound
and I would like to add a progress bar based on the number of lines given on stdin
(so that the progress can be accurately monitored).
How can I count the number of lines from stdin
, and let the while read loop operate on it? (without using temporary files, if possible)
PS- Code for progress bar to find at How to add a progress bar to a shell script?.
UPDATE -- Is it possible to not add a parameter to filenotfound
, and get what I want through the usage of tee
, subshells or things like that?