Instead of typing "control+c" to stop the 'top' display in the terminal, you can press the "q" key.
Simple.
[Editor's note: Whoops, see comments ... I thought this was undocumented, but clearly, I just can't read early in the morning! Thanks for the clarification, and I'll try my best to catch these in the future.]
One of my absolute favourite *nix-tools is screen. It allows me to start a lengthy and possibly talkative and interactive process and then detach from it at will. I can later attach to the process and then enter right into where it is at the moment.
You can install screen using fink (which has been discussed previously on macosxhints.com), or you can download the source and build it yourself from the screen home page on gnu.org.
Read the rest of the article for a theoretical example of how to use screen once it's installed.
Here's a shell script that clones an entire Mac OS X file structure from one location to another. Though not an original concept here on Mac OS X Hints, the script demonstrates a good assortment of shell scripting tricks that every OS X geek should get to know.
[Editor's note: We have published articles in the past that discussed cloning the system. This script looks to be another valid method of doing the same thing, so I felt it worthy of publishing on its own. I have not tried the script myself.]
tcsh will consider it an error if it can't find a file matching an expression, and instead of executing it, it will print [cmd]: No Match. This makes it difficult to do things like:
find . -name [Mm]ac*
which works in bash (I do that a lot on linux as bash is the default shell). It takes some effort to properly escape the bracketed area, and I normally don't want to quote everything.
Another example is when typing URLs - the ? is used as a separator and results in the same error. To change tcsh's behavior, simply type:
set nonomatch
This will tell tcsh to NOT consider expressions with wildcards that don't match any file an error. Most apps will tell you if things are actually missing, but in the rest of the cases where the characters are intentional, it will work.
[Editor's note: I have not tried this myself, but I do have a question on it -- anyone know how to UNSET this option once you've set it?]
I was having a problem when I wanted to insert, in MySQL db, any french characters like "é" or "Ã " for exemple. The terminal was always giving me "??" instead. This was also true when connecting to my Linux/MySQL server using SSH. Keep getting those "??" when doing a SELECT FROM.
Simple fix: - Open Terminal app and go in Preferences. - In the Shell section, choose "ISO Latin 1" in the String Encoding menu.
Do you run sendmail, like to have a secure system or does it just plain annoy you that Apple's installer messes with the root permissions. If so, then here's a place to put the script which will save you having to remember to do it yourself.
The script /etc/daily, which runs as root automatically does some tasks each day. However, I'm loathed to mess with these scripts - it's really nasty to install stuff in global scripts, there should be some way to customize without hacking arround to much. Well, there is. /etc/daily checks for a script /etc/daily.local which doesn't exist by default. I'd suggest putting the following in that file (and ensuring it has appropriate permissions). This will keep your root directories permissions neat without much work.
A recent post to the java-dev mailing list had a great script I thought I'd pass along. It allows you to make OS X disk images (.dmg) from any directory with a simple command in the terminal, like so:
I don't know how I missed this before. As a new Unix user, I often don't quite type terminal instructions correctly on the first attempt. Usually, I would "up arrow" to retrieve the last command, and then backwards cursor through the command--but if the filepaths were long, I might have to go through several lines of text to correct just one or two characters of typo. The terminal being the terminal, it wouldn't respond to positioning the cursor with the mouse--or so I thought.
Well, in the terminal preferences, under the last option "Emulation", you can turn on "option click to position cursor." Which allows one to 'option click' in any command and have the cursor positioned under the mouse pointer. Particularly useful in pico, so you don't have to scroll through the whole config file.
Having put together some incremental backup software, I was very annoyed to find that cron wasn't running the /etc/daily script because cron doesn't run while my computer is asleep, and my computer is always asleep at 3:15am when /etc/daily is set to be run.
So, I made a very simple perl script that fixes this problem. It checks the modification times for the daily, weekly, and monthly log files. If they are more than a day, week, or month old, respectively, it runs the appropriate commands.
I've noticed that over the months that I have been reading macosxhints.com, a lot of hints advise to do UNIX level things which are not proper. They usually get the job done, but poorly. Most of these involve hint giver's confusion over when to use the various Library directories. So I decided that although many users know this information, it may be a good idea to explicitly say it.