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

10.4: A c-shell alias for searching via Spotlight UNIX
Tiger only hintThis hint is motivated by this earlier hint, and other stuff I've read elsewhere. I created a csh alias to search via Spotlight. Results are returned in chronological order and logically grouped.

Here is a detailed description of the construction of the alias, so that readers can modify it to suit their own needs. The alias has five parts connected by four pipes. To reassemble the alias, put the five parts on a single line and add it to your .cshrc file.

As a summary, here's how it works. If one types:
 $ spot xanadu 
mdfind is asked to find all files in the current directory containing xanadu in their metadata. The output is piped to ls -lt, to sort it into chronological order (most recent at the top). The result of this is then piped to sed for tidying. Read on for the details...
read more (284 words)   Post a comment  •  Comments (9)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[11,188 views] Email Article To a Friend View Printable Version
Find duplicate Address Book entries via a script UNIX
I was looking for an AppleScript that would just show me the duplicate entries in my Address Book, and not delete them out of hand, since some have different information yet the same name. I could not find one, but found this great gem from Apple Developer Documentation - Apple Script:
osascript -e 'tell app "Address Book" to get the name of every person' \
| perl -pe 's/, /\n/g' | sort | uniq -d
It will give you a nice listing of every duplicate entry in the Address Book, making it easier to sort through them for information and delete them individually.

[robg adds: Address Book's Card: Look for Duplicate Entries feature doesn't provide much information at all prior to merging -- it will just say "one duplicate card was found; do you want to merge this data?," without telling you which cards are duplicates. This script will let you verify which cards may be merged, prior to doing so. Note that the script is based simply on name matches, so you may see more duplicates listed via its ouput than you would with Address Book's duplicate feature.]
  Post a comment  •  Comments (18)  
  • Currently 3.78 / 5
  You rated: 3 / 5 (9 votes cast)
 
[35,112 views] Email Article To a Friend View Printable Version
10.4: A collection of 'Spotlight from Terminal' tips UNIX
Tiger only hintI just wrote a detailed article on using Spotlight from the Terminal. Here are a few tips from that article:

Example 1. A Basic Spotlight Query

The commandline version of Spotlight is mdfind. Simply provide your search query as a parameter and let it run.

evil:~/Desktop mohit$ mdfind Rails
/Users/mohit/Documents/Rails4Days.pdf
/Users/mohit/Documents/Agile Development with Rails.pdf
/Users/mohit/Library/Mail/POP-foobar@mail.snip.com/INBOX.mbox/Messages/20455.emlx
/Users/mohit/Local/rails
/opt/local/lib/ruby/gems/1.8/cache/rails-1.0.0.gem
/opt/local/lib/ruby/gems/1.8/gems/rails-1.0.0
/opt/local/lib/ruby/gems/1.8/gems/rails-1.0.0/bin/rails
/opt/local/lib/ruby/gems/1.8/gems/rails-1.0.0/builtin/controllers/rails_info_controller.rb
/opt/local/lib/ruby/gems/1.8/gems/rails-1.0.0/html/index.html
/opt/local/lib/ruby/gems/1.8/gems/rails-1.0.0/html/images/rails.png

The files that are listed also include files with content and metadata that matches the query expression.
read more (113 words)   Post a comment  •  Comments (5)  
  • Currently 4.00 / 5
  You rated: 3 / 5 (6 votes cast)
 
[14,578 views] Email Article To a Friend View Printable Version
A network interface status script for GeekTool UNIX
I love GeekTool and use it all over my desktop. So I thought that I'd share the script that I use to keep the status of my network interfaces on my desktop at all times. Please pardon the fact that it's written in csh, but I'm a long-time SunOS user, and that's what I use for most of my quick and dirty stuff.

Here's the code:


#! /bin/csh
# 2006 Beerguy's Reef - www.hopdog.com
#

foreach if(`ifconfig -a | grep ^en | awk '-F:' '{print $1}'`)

/sbin/ifconfig $if > /tmp/if-stat

set addr = `cat /tmp/if-stat | grep 'inet ' | awk '-F ' '{print $2}'`
set speed = `cat /tmp/if-stat | grep media | awk '-F: ' '{print $2" "$3}'| head -1`

echo $if": "$addr $speed
rm /tmp/if-stat
end

If you'd just like to download the script, you can grab it here. You can call it as a script from GeekTool, or just run it in a Terminal. The output looks like this:
en0: 10.0.1.11 autoselect (100baseTX <full-duplex>) status active
en2:  <unknown type> status inactive
[robg adds: This works as described...]
  Post a comment  •  Comments (4)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[17,625 views] Email Article To a Friend View Printable Version
A fix for a miscolored X11 cursor on Intel Macs UNIX
You may have noticed in a few rare instances your cursor in X11 becomes a transparent yellow outline. This is caused by a byte-order bug in Xquartz, in the instance your remote machine changes the cursor's appearance using an image rather than just a bitmap. (RedHat Linux systems do this to get a neat blue facet.)

Use the following if you have this problem. Do not apply this fix if you're running a PowerPC Mac.

Quit X11. Grab this file (2.7MB)) using Safari or command-line wget, then run this command:
sudo tar zxvf xfix.tar.gz -C /
Restart X11. The new binary simply adds a loop of ntohl() to the ARGB image in load_cursor(). A simple modification to quartz-cursor.c, found in X11-0.40.2 -> xc -> programs -> Xserver -> hw -> apple.
  Post a comment  •  Comments (32)  
  • Currently 2.33 / 5
  You rated: 3 / 5 (9 votes cast)
 
[52,437 views] Email Article To a Friend View Printable Version
10.4: Permanently increase the process limit UNIX
Tiger only hintThis is not my hint, but I'm reporting it here after seeing it posted elsewhere. Phillip Moore found a solution for occasional tcsh: no more processes and similar errors. Check his original post for details and the discussion.

One modifies /etc/launchd.conf by adding this line:
limit maxproc 512 2048
A restart is then required to activate the new settings. Or find some other way to restart launchd, which I didn't feel comfortable doing. I'd run into this problem sometimes after opening multiple Terminals and running a bunch of shell scripts.

[robg adds: As Phillip notes on his page, you only need to do this if you've run into the 100 process limit before; there's no other reason to do it. Visit his page for more details on the settings...]
  Post a comment  •  Comments (7)  
  • Currently 3.00 / 5
  You rated: 4 / 5 (4 votes cast)
 
[13,486 views] Email Article To a Friend View Printable Version
10.4: Character conversion with textutil UNIX
Everyt ime I have come across hints about textutil, I have tried to use it for converting text files between different character encodings.

According to the documentation, textutil should be perfect for this. However, it has never worked. Until now. It seems like the -format and -convert flags must be specified, too. This example converts a macroman encoded file to latin-1:
textutil -format txt -inputencoding macintosh -convert txt \
 -encoding iso-8859-1 mytextfile.txt
  Post a comment  •  Comments (3)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[8,237 views] Email Article To a Friend View Printable Version
Easily verify md5 checksums on files UNIX
I've found an easier way to check an md5 sum, or any other checksum for that matter. Just use this command:
md5 file_to_check | grep checksum_of_file
If there is an error, it will show the file name and the real checksum of the file. If there aren't any errors, then nothing will show up. You can do this for mutliple files by putting a semicolon (;) between the above code for each file.
  Post a comment  •  Comments (6)  
  • Currently 3.50 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)
 
[46,420 views] Email Article To a Friend View Printable Version
10.4: Batch text conversion with textutil UNIX
Tiger only hintI first learned about textutil in Mac OS X 10.4 in a tip here on macosxhints.com.

textutil is a rosetta stone for converting between different text file formats. For example, I recently wanted to change 36,000 .doc files into text files. So I needed to come up with a way of recursively converting all the files. The unix find command can be used to feed textutil. In Terminal, navigate to the appropriate directory (since this uses the current "." directory), and enter this command:
find . -name *.doc -exec textutil -convert txt '{}' \;
Read aloud: Find recursively in the current directory, by name, all the doc files. Execute the textutil 'convert to text' command with the found files. Bingo, done.
  Post a comment  •  Comments (16)  
  • Currently 3.50 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)
 
[22,950 views] Email Article To a Friend View Printable Version
A simple 'graphical' calculator script for Terminal UNIX
It has always annoyed me that a simple calculator would take several seconds to load on my current machine, and yet MacOS Classic's calculator is instantaneous even on my 33mhz 68k Mac. xcalc is also instantaneous, but requires x11 to load, which takes a while.

As I'm always running Terminal.app anyway, I thought a terminal calculator with a 'GUI' would be nice. After googling for it with no luck, I decided to write a shell script that mimics the behavior of a simple calculator. It loads instantly even on a iMac 233, although screen redraw can be a little sluggish on such hardware.

Here's what it looks like, and the result of your calculation is copied to the clipboard.

I'm not a developer in any way, so the code is probably the ugliest thing ever written, but it works for me. It handles only the basic 4 operations with 5 decimal cases. type 'q' to quit, the rest should be self explainable. Improvements are more than welcome -- for example, I couldn't map the clear key in the numeric pad, so I used 'c' for clear.

[robg adds: I mirrored the script here on hints. Remember to make it executable first (chmod a+x tcalc). I tested it, it seems to work well, and it is indeed speedy.]
  Post a comment  •  Comments (18)  
  • Currently 2.25 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)
 
[12,730 views] Email Article To a Friend View Printable Version