Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 237
  • Last Modified:

remove files recursively

I ever asked questions about find files recursively and rename a set of  files in current directory.
the following command , which can remove files with extension .a recursively,  is based on the answers.

 find pathname -type f -name "*.a" | sed -e 's/\(.*\)\.a/rm \1.a/' |sh

I feel I make it complicated. Is there other way to do it?
Thanks
0
tian
Asked:
tian
1 Solution
 
ecwCommented:
The safest
 find pathname -type f -name "*.a" -exec rm '{}' \;
or quicker, but not as safe
  find pathname -type f -name "*.a" | xargs rm
or if total length of all filenames will not execeed ARG_MAX
 rm `find pathname -type f -name "*.a"`

0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now