How can I save the output of this command into a var and still remove the files?
rm -vri files | wc -l
How can I save the output of this command into a var and still remove the files?
rm -vri files | wc -l
you can use something like
rm -vri *.txt | tee rm.out
just make sure your rm wildcard pattern does not cover the output file
Since the question is very precise, the answer is short
VAR=$(rm -vri files | wc -l)
Update just in case one has more interest on the subject, here is the link to command substitution