Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Why does no-one use zsh???' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Why does no-one use zsh???
Authored by: gidds on Aug 23, '06 03:21:31PM
It's free and open source, it's supplied as part of Mac OS X, it does pretty much all that ksh and bash do (in fact it can pretend to be ksh), and it has really cool features like recursive file completion which can turn that rather unwieldy
find /path/to/folder/* -type f -mtime +90 -exec rm -f {} ;
command into the rather simpler
rm -f /path/to/folder/**/*(.m+90)
command. (The ** means to search subdirectories recursively, the . includes only plain files, and the m+90 includes only files with a modification time more than 90 days before now.)

It can do far more than that, of course, but this is a rather good example. (I should point out that I didn't have to look anything up; the common criteria are fairly easy to remember, and when I tried that command just now it worked first time.)

Recursive file completion (the ** bit) seems like such a no-brainer that I'm still amazed the more common shells haven't copied it yet. I don't think I've used find once since I found out about it, as it can do all of that and more -- and because it's right there in the shell, you can use it in really powerful ways.

You can run zsh by name at any command prompt, and you can set it as your default shell in NetInfo Manager or (if it still works) the chsh command.

---
Andy/

[ Reply to This | # ]

Why does no-one use zsh???
Authored by: S Barman on Aug 23, '06 08:06:36PM
The recursive directories do work in bash and csh, but not the modifier (.m+90). That appears to be a zsh only construct. But you can use it in an automator by entering the command as:
zsh -c 'rm -f /path/to/folder/**/*(.m+90)'
Note that the quotes are necessary to prevent the current shell from trying to interpret the path.

[ Reply to This | # ]
Why does no-one use zsh???
Authored by: dmetzcher on Aug 25, '06 01:53:25PM

Excellent!
Here is a script that can be used to remove older the contents of a folder.
This really helped me a lot, as I was just trying to figure this out the other day.
=======================
-- Get the path to the home folder of the current user.
set homeFolderPath to (path to home folder) as string
-- Set myPath to the home folder, and add the folder within the home folder to the end.
set myPath to homeFolderPath & "Backups:Firefox"
-- Convert the full path to the required folder to the POSIX path so that it can be used in a shell script.
set posixPath to POSIX path of myPath -- convert the path of the file to a POSIX path (uses slashes (/) as directory separators. e.g., 'macintosh hd/users/johndoe/desktop'

do shell script "zsh -c 'rm -f " & quoted form of posixPath & "/**/*(.m+2)'"
=======================



[ Reply to This | # ]