I have to find files with selected permissions and list them as well as their number. Therefore I would like to pipe result of find
command to shell and to the next command, which output I want to store in a variable so I could display it nicely later. I would like to have something like
for i in "$@"
do
find $filename -perm $i | tee /dev/tty | var=${wc -l}
echo "number of files with $i permission: $var"
done
but var=${wc -l}
part doesn't work. Please help.
EDIT I'm aware that I can put entire output of the command to a variable like
var=$(find $filename -perm $i | tee /dev/tty | wc -l)
but then I need only the result of wc -l
. How would I get this number from that variable? Would it be possible to display it in reversed order, number first and then the list?