Find the answer to your Linux question:
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.
  1. #1
    Just 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?
    Code:
    find . -iname "*wine*" -exec rm -rf {} \;
    thanks!

  2. #2
    Linux User cyberinstru's Avatar
    Join Date
    Jan 2007
    Location
    India
    Posts
    362
    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
    ---------------------------------

  3. #3
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    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.:
    Code:
    find . -iname "*wine*" -exec rm -vf {} \;|wc -l
    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).

    @cyberinstru, i love your avatar (that was me @halloween many years ago...)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •