|
|
zsh does all this!
I hope no-one minds me going on about it, but if you use the zsh shell instead of more primitive ones like bash, then the filename completion is so powerful you never need to use find.
For instance, the example above to set ownership of all a user's files, which using find looks like: find / -user foo -exec chown bar {} ;can be written in zsh as chmod bar /**/*(u[foo])Not only is this shorter and easier to write (once you're familiar with the idiom), but it's likely to run much faster as it only launches the chmod utility once, rather than repeatedly for each file. To briefly explain that cryptic-looking search string: I'm sure you're all familiar with using * in a shell to give a list of all files in a directory. Well, in zsh you can list files recursively: **/* lists all files in all subdirectories. So /**/* lists all files starting at the root directory. The bracketed expression restricts the files returned; in this case, it restricts them to the user `foo'. To restrict them to the current user, you'd simply use (U). The syntax is extremely powerful: it's easy to restrict files based on filename, time of creation/last modification/access, permissions, size, type, links, with exclusions, ordering, in fact everything find can do and more. And because it's not in a separate command, you have all the power of the shell in how you use the results. I'm amazed more people don't use zsh; it's extremely powerful in many other ways too. Not only is it supplied with Mac OS X, but it's open source and available on many other platforms, and is backwardly-compatible with ksh for those who know that. man zsh for more details. You can change your default shell with the NetInfo Manager. (BTW, I have no connection other than as a happy user!)
zsh does all this!
Hey Gidds
zsh? Now that's a tip! Thanks. I think I'll have a look into it - both for my FreeBSD box and my first Mac (12" P-book) when it arrives. Looks great - and simple! Cheers! |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.14 seconds |
|