What I really was missing on OS X so far was a small mailchecker. There are several programs for mail checking, but each one I tried takes almost as much RAM as Mail.app, which I use. So I wrote a little script, run by cron, which checks whether there are new mails (using fetchmail) and fires up Mail.app if there are.
Read the rest of the article for the script and installation instructions.
The powerful command-line 'screen' utility (see this hint for help installing screen) can handle multiple "windows" within the same screen session. It's quite like tabbed browsing in Mozilla or the way kterm works in KDE.
To create a new window you press "Ctrl-A c". To cycle forward through the list of windows use "Ctrl-A n"; backward is "Ctrl-A p", and "Ctrl-D" to terminate the screen. Assuming you have 'screen' installed, here's a quick example:
% screen top [Ctrl-A c]
% screen man tcsh [Ctrl-A c]
% man screen [Ctrl-A n] [Ctrl-A p] [Ctrl-A n] etc [Ctrl-A n] until 'top' is onscreen q [Ctrl-D] [Ctrl-D] etc...
Or something along those lines. You don't need tabbed terminal apps after all. =)
Yes, this is documented in screen's man pages. But it's one huge man page and I thought maybe you'd be more inclined to read it if you knew great stuff like this are hiding there.
The standard UNIX (command-line) utility 'diff' compares two text files, showing you the lines which differ between the two. It works well for all UNIX text files, including most of those you will encounter in OS X (e.g. the plist files holding preference information).
But it isn't useful for comparing files which use the traditional Mac end-of-line marker ("\r") since the 'diff' utility, like most UNIX tools, expects lines to be ended with "\n". OS X itself and most OS X applications use "\n" as the end-of-line marker, but some applications which exist in both OS 9 and OS X versions use the traditional Mac "\r" end-of-line marker for their files. An example is iMovie - its project files are editable text but they use "\r" and hence cannot be usefully compared with 'diff'.
All of the above was a long-winded motivation for the following shell script (for use in the Terminal) which provides a 'diff' comparison of two traditional Mac ("\r") files. Read the rest of the article for the script...
I'm a big fan of the PERL scripts that have previously been posted here, especially the command line speech generator and the command-line alarm clock. I use these two so frequently that I wrote a script to go with them; it gets the current weather and daily forecast off of weather.com, outputting the information in an speech-friendly way. To use this script, you must have wget installed, which you can do in a number of ways (This hint explains how, or through fink if it's installed, or via macosx.forked.net).
The System Prefs panel makes it easy to change or add IP addresses, but what if you want to do it automatically or remotely? Most Darwin documentation talks about a nifty, "nonexistent since the Public Beta" tool called ipconfigd.
After much, much experimentation and research, I learned that to successfully change IPs from the command line the hard way, you must manually create a ton of routes. However, the ipconfig tool (not ipconfigd, which is now a plugin to configd) will do much of it for you. After manually setting the ip address of your interface (probably en0), just delete the current default route and recreate a route to your router.
Read the rest of the article for a script which uses this fact to automatically assign the next available IP using this technique.
[<b>Editor's note:</b> I have not tested this script.]
This trick may be obvious, but by combining a couple commands in the Terminal, you can search the descriptions of all the commands in that path. Open a Terminal and type:
% whatis /usr/bin/* | grep "search string"
This will return the description of every command in that path and then filter it with your search string. This is a quick way to find a way of doing something, if you don't know all the commands. For example:
% whatis /usr/bin/* | grep "memory" leaks(1) - Search a process's memory for... vm_stat(1) - show Mach virtual memory statistics vmmap(1) - Display the virtual memory regions...
These example results were trimmed for width, but you get the idea...
[Editor's note: You can use this syntax to find anything on any path, of course. If you're just interested in user commands, you could also use man -k "search string" | grep \(1 to return the same results a bit faster. The 'whatis' version of the command will also only work if you have built the whatis databases - see this hint for more about the 'whatis' database.]
Just found this over at the macnn.com forums (credit to kennethmac2000 for that). There is no real command for doing portscans in the Terminal, so instead of installing nmap, just use the Network Utility from the command line like this:
Add the following alias to your aliases.mine file to have an on-call dictionary at your fingertips:
alias dict 'curl dict://dict.org/d:\!*'
Now to look up a word, just type dict word_to_define.
[Editor's note: There's at least one service (OmniDictionary) which will return the definition of a selected word if you prefer the GUI for your dictionary browsing ... but this is quite nice when you don't want to touch the mouse or the menu to define a word. Note that I have substantially (completely?) rewritten what Carthag submitted ... primarily because, although it was fun reading an IRC transcript, it really didn't fit the layout of the macosxhints page all that well! ;-)]
In the Finder, it's relatively easy to see how many files are within one level of a folder, but I'm not aware of a way to see a count for all of the files in that folder hierarchy (anyone?).
Someone asked a similar question on the Macworld forums, and with some help from a friend, we managed to come up with a UNIX command string that will return the answer. Say you wish to count all the files in the folder "Stuff" stored on your desktop. Simply type the following into the Terminal:
% cd ~/Desktop % find "Stuff/" | wc -l
This will return a count all files, including invisibles and the top level "Stuff" folder itself. If you just want to see the visible files, use:
% find "Stuff/" \! -name ".*" | wc -l
I'm not sure if this is the most efficient means of answering the question, but it seems to work reasonably quickly and it was accurate on all the folders I tested it on. Any other alternatives, in either the Finder or the Terminal?
If you'd like to know more about how the command works, or how to create a shortcut to make it easier to use in the future, read the rest of the article.