1

How can I save the output of this command into a var and still remove the files?

rm -vri files | wc -l

2 Answers2

1

you can use something like

rm -vri *.txt | tee rm.out

just make sure your rm wildcard pattern does not cover the output file

MelBurslan
  • 6,966
0

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

Tagwint
  • 2,480