Re:Why "ls *.c" is at least dumb, and possibly dangerous
by BrandonM on Friday October 09, 2009 @02:47AM
(#870764)
Why not just
find . -name "*.o" -delete
?
Re:Why "ls *.c" is at least dumb, and possibly dangerous
by michaelcampbell on Friday October 09, 2009 @09:32AM
(#871303)
That's fine for /this/ example because find provides that as an option. But you might want to grep for something in many files of varying depths, or run some home-brewed script on them for which find does not provide a built-in. -exec works of course, but spawns grep (or whatever) once per file; using xargs saves considerable time since it passes lots of files to 1 command.
Or, you can use zsh.
rm **/*.o
grep foo **/*.{java,sql,xml}
# Where is that blasted IBM utility?
ls **/*pmt*(x.) # list e(x)ecutable files (.) that have "pmt" in their name.
# Show me all the "Setup" dirs in my project
ls -d **/Setup(/)
For example, to delete all .o files in the current directory and its subdirectories: