Results 1 to 3 of 3
hi
is there a way to get the terminal to display the number of files that were deleted by this statement?
Code:
find . -iname "*wine*" -exec rm -rf {} ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 08-30-2011 #1Just Joined!
- Join Date
- Aug 2011
- Posts
- 10
How To Get "# of files deleted" From RM Command At Terminal?
hi
is there a way to get the terminal to display the number of files that were deleted by this statement?
thanks!Code:find . -iname "*wine*" -exec rm -rf {} \;
- 08-30-2011 #2
One possible way is to run 'rm' with verbose option and pipe it to 'wc'.
Not sure if 'echo $?' will show the deleted number of files.---------------------------------
Registered Linux User #440311
HI2ARUN _AT_ GMAIL _DOT_ COM
---------------------------------
- 08-30-2011 #3Trusted Penguin
- Join Date
- May 2011
- Posts
- 3,673
Just to add to cyberinstru's good solution, you'd want to add the "-l" flag to wc in order to count just lines, e.g.:
and the $? definitely will *not* contain the number of files deleted. As with most command line tools, it will contain the command's EXIT STATUS (run 'man find' for details).Code:find . -iname "*wine*" -exec rm -vf {} \;|wc -l
@cyberinstru, i love your avatar (that was me @halloween many years ago...)


Reply With Quote
