Just how geek was your week?

by Erica Sadun

I've had a very terminal/command-line based week as I've been hacking away at the Zune/Mac interface with the help of the brilliant and patient Richard Low. This morning, when I called up cal rather than waiting for iCal to launch, it occurred to me to wonder how much time Mac people really do spend at the command line. When was the last time you used cal? ed? egrep? sed? What are the geekiest tools you used this week? Let me know in the comments or drop a line to erica@mindspring.com with your geek stories.

30 Comments

Jim Kirk
2006-11-30 15:39:15
All day, every day. Hell, I use cal at least once I day, I bet. It is way faster than launching calendar and then having to mouse around to find the date you need. The fact that I write code in vi and/or emacs all day long is something of a cheat, though. In my case, the more interesting question is what gui apps do you use besides a web browser and iTunes.
sauerkraut45
2006-11-30 16:40:02
just yesterday, i ssh'd into my supervisor's new macbook pro, su'd to his account, and open'd iChat.app, just to invite him into a video ichat. wow!

2006-11-30 16:41:48
I use command line FTP with a .netrc file that contains a init marco. In fact, I used it so much, I didn't even realize I had changed my password and Fetch no longer worked. I also use vi to build my webpages.


I don't use "ed" and "cal", but I am a heavy user of sed, egrep, and awk with some of my scripts running into a few hundred lines. Most of the time, I simply write a short shell script right from the command line. I also use the command line "svn" and "p4" commands for version control.


One of the reasons I like the Mac is because OS X is Unix based, and has all of my old command line friends. You can't do that type of stuff on a PC with out spending hours downloading Perl, cygwin, VIM, and other utilities.


2006-11-30 17:10:20
All day every day. I'm ssh'ed into work all day long, and scp/ssh back and forth between my desktop and laptop. I do most Finder-style activity from the command line, and usually prefer to use locate(1) over Spotlight. I use rsync to keep snapshots of all my critical files, and to take system-wide backups. Not this week, but last week I had an Xterm open several times, and used it to access X11-based RAID utilities on my work machines. This week probably the geekiest thing I've done from my Mac is to update ruby from Mac Ports.


The fact that OS X is Unix-based and has full access to the command line is what enticed me away from the Windows world in the first place.


kris
2006-11-30 19:18:21
ssh, scp, and sftp. also just discovered split and sort for scrubbing text... i'm afraid my sed skills are nil at the moment!
gwhilts
2006-11-30 19:56:05
I have cal and scripts utilizing netstat, ps, who and lsof running on my desktop via GeekTool and usually at least one Terminal window open.
Geoff
2006-11-30 20:10:19
I use ftp/sftp a lot. It just seems faster and easier for quick and dirty file transfers. I ssh into a Solaris server fairly often to check on things


I event have a shell script to pull down an rss file, process it, convert to html and make it into an html email newsletter.


I still need to learn more though, especially grep. Once in a while I use split to make large files fit on DVD or CD

Michael Clark
2006-11-30 20:37:31
I use ssh, cal, grep, sed, awk quite frequently. And I'm always learning new commands. Just this week I needed to wrap some loooong lines of text at 80 characters. A google search pointed to a handy tool called "fold." Many hours of programming or cutting down by hand were saved.
Andy
2006-12-01 02:07:39
I grep -r my web site source code several times daily - it's quicker and easier than spotlight (at least, for that limited subsection of the file structure).
Billifer
2006-12-01 02:50:45
The geekiest tool I've used this week? Just within the last hour, I've written a shell script to be called inside an Automator workflow as a Finder CM item, which takes audio files as input, determines whether they are raw (PCM), aiff, or wav (it matters), then uses lame to encode them to MP3. The rest of the workflow then adds the newly-encoded MP3s to iTunes (in their own special playlist), and tags them appropriately. You can imagine there are several sed's, grep's, and test's in there.


It's not uncommon to find me playing with kextstat/-load, tinkering with DirectoryService, etc., but...


The really geeky thing I've been working on this week — this one takes the cake — I've been writing my own keyboard layout. I don't like the default US keyboard, and the US-Extended is only a little better, but what I want just isn't on the 'board. So I'm making one. And it's a pain in the butt. Thankfully, there's Ukelele from SIL.


It least this wasn't the week when I went in and had to fix my Firewire interface inside the OpenPROM.

Kurt
2006-12-01 05:25:29
I about 50-90% of my day within X11 mostly with xterm, emacs, and make crunching through data with python. That apple GUI tuff is just back there as support... for the occasional email/google/photoshop task.
John
2006-12-01 06:35:03
ssh, scp, cal, bc, sed, grep, awk, sort, cut
MB
2006-12-01 07:57:57
I am a Unix/SAP admin, so I'd say about 6 hours a day minimum. In fact, right now I have 10 term windows up, which is about average.


I use OSX mainly for the tight X11 integration, which is handy for SAP, TSM and DB2 on Unix. Well, that, and an SSH that works. Simon Tatham's PuTTY is nice and all - but it's not perfect.


MB

neuwalker
2006-12-01 09:22:53
In our college we use a Mac mini with Tiger (client-version) as a airport router to connect all iMac to the internet. Now, all iMac should talk to each other - but their are no routes defined. I used netstat and route, but it is not working yet. All Clients can ping the server/router and the server/router can ping all clients, but the clients can't ping each other. Very geek day.
Hans
2006-12-01 09:55:35
Hi Erica,


Hmm, let me see


On monday I logged into some 13 Linux boxes, do a little grep, some awk, etc...
Thursdays are normally my fun days. I get to log into AIX, Tru64 and HP-UX where I run a few maintance scripts :-) Since I was busy coding c-sharp on that day I had to postpone it to today. Next I installed debian on vmware, used a little apt-get, etcc... installed some webapplications, enabled access to a central dbserver for them.


All on the command line :-)


B.t.w., I do use the terminal on osx too, to create makefiles in order to be a lazy bum so only on command will put mono compile and pack cli apps for me :-)


Regards,


Hans (osx lover)


p.s. I did use a gui to paste it in here :-)

FARfetched
2006-12-01 11:28:32
I use groff for a series of manuals I maintain at my day job, totaling about 750 pages. I'm currently maintaining two versions (~750 pages each) and may have to spawn a third branch this afternoon -- so CVS gets a workout as well. All that gets supported by various awk and shell scripts that do things like build indexes, wrap bitmap graphics in EPS, or clean up groff-generated HTML and prepare auxiliary files for OmniHelp.


All of that is driven through makefiles, so one command kicks it all off. It's literally 15-20 times faster than FrameMaker for building PDFs.

Alastair Rankine
2006-12-01 13:37:48
Erica, I was inspired by your article on iPod notes. I wrote a shell script to download the contents of my personal wiki (using curl), and process the resulting html files to format them for use as iPod notes. For this I'm using an XSLT stylesheet and xsltproc. Will post the script on my blog when it's done.
Erica Sadun
2006-12-01 13:45:05
Alastair: Very cool! Let me know how it goes.
Alastair Rankine
2006-12-01 15:46:16
OK, here it is, a script to download a wiki, and format the contents for display on an iPod. Enjoy, and let me know what you think.

2006-12-02 01:52:08
At the university I go to we use matlab, which is simply way too expensive, hence i spend a lot of time with three terminals at home - one for vim, one for ssh and one for sftp so it goes write-upload-test... in the winter i can hardly imagine anything more fun than sitting at home with a hot mug and writing code (bleeding edge: vim 7.0.174, openssh 4.5p1 (openssl 0.9.8d)
Billifer
2006-12-02 18:36:55
Argh! I've been fighting with a humongous find command for a day or so now because I can't quite get all the -or's and -regex's to do what they're supposed to.


All I wanted to do was create a new subdirectory in every directory of the current one (find . -type d -exec mkdir {}/.backup \; , right?), but I want to make sure to exclude all the "special"-type directories, such as applications, bundles, etc., so eventually I get something like this:

find . -type d -not \( -regex '.*/*.app*' -or \
-regex '.*/*.bundle*' \) -exec mkdir {}/.backup \;
But those regex's don't match! So I try adding the -E flag to tell it to use extended RE's; still no good. Then I switch the RE to '.*.app*' and it still picks up the .app directories.


So then I said *&$^ it and just executed a find . -type d > alldirs and loaded alldirs into gvim, where I tried using its 's' motion command to accomplish the task to delete the lines I didn't want — :%s/^./*.app\/*//g to replace each of those with nothing, but I found that the regex engine in vim isn't greedy and wouldn't eat the whole line. I tried forcing linewise mode by adding a V after the s, but that didn't help either.


Can anyone (Erica? other regex or find gurus?) offer a hand? I want to exclude all .app directories and all the directories under them, as an example. I used to be a Unix guru, but I concede that this one has kicked my butt.

Erica Sadun
2006-12-02 18:40:18
I think I'd just have done a recursive ls, grepped for the "/"'s and then edited the results to make a shell script.

2006-12-02 23:31:08
Billifer - the REs in find aren't shell globs, so your pattern '.*/*.app*' only matches when "ap" follows a sequence of "/"s and is followed by a sequence of "p"s. You would want ".*/.*\.app.*".


I'd have used -prune to avoid descending into the bundles - something like


find -E /Applications -regex ".*\.(app|bundle)" -prune -o -type d -ls


if you're sure there are no other bundles you need to avoid, like .rtfd. Anyone know a command line tool for asking if a directory is a bundle?

Billifer
2006-12-03 03:21:27
Erica and Anonymous, thanks for the tips! Two very different answers from two different people. I knew that -prune would make things easier, but that was part of what I couldn't remember since it had been so long since I'd done such a complex find.


As for the command-line "is this a bundle?" tool, try this one:


if ( mdls -name kMDItemContentTypeTree filename | grep -q \
\"com.apple.package\" ); then
    .
    .
    .
fi


Hmm... I think that just answered my question too. This has been a fun and useful thread, Erica!

Erica Sadun
2006-12-03 20:24:18
Hey, Anonymous: Matlab has a free beta out right now for students. You might want to check it out.
xman
2006-12-03 22:12:10
When the company is 24/7 and I want to stay at home, then ssh is your friend. nano is not far behind, since it's there. and it's not much different from emacs, or pico, from my old uni days. nmap is at the heart of some of my custom network monitoring scripts, and Mac Ports and Fink are always downloading something new I need. I'm so glad I learned the unix basics in school (when checking email involved command-line) because MacOSX and *NIX are a great pair. I'm usually staring at a dozen Terminal windows all in different colors, SubEthaEdit is my script editor of choice, and ard3 client installed on every OSX box gives us access to kickstart, systemsetup and network setup. Sweet stuff. Still trying to grok awk after all these years, but find does have to be the coolest command ever. bar none.
fondomatic
2006-12-04 05:36:39
I installed & added the following to my .bash_profile:


- cal3col
- gina's todo.txt
- fortune


Here's my 'refresh' script:


clear
echo
./.cal3col
echo "Priority 'A' tasks:"
echo
./.todo.sh listpri A
echo;fortune;echo

Brian Cooke
2006-12-05 21:31:08
The first thing the Geniuses at the Apple store noticed when I took my Powerbook in for a minor repair was my open terminals.


At any given moment there are at least two or three iTerm sessions going. TextEdit? What's that? I drag files onto vimdrop and they open in vim, and I use perl, egrep, ssh, sed, awk, cal, and numerous others all day, every day.

Laurel Maury
2006-12-18 10:59:27
Hi,


I use sed and awk for playing with xml at the magazine where I work. But I've found--to my horror--that grep and egrep do not behave as they ought on my machine. Trying to figure out what's up with this...


Mostly I take a bunch of UNIX commands, get them working and then bundle them into something else (like Applescript or, believe it or not, FileMaker Pro using a deft little tool called yooShell) and then forget about them.


However, using the full range of UNIX from Applescript is a headache and a half. Applescript doesn't except the full range of characters that UNIX does. My feeling is that, if Applescript is ever going to grow up and be a real boy, rather than a creature of wood, it will need to learn to play nicely with UNIX.


Best wishes,
Laurel Maury

Kumar Chetan
2007-07-05 01:29:54
I have been doing ssh playing with a remote Mac Mini, I was "advised" to use remote desktop, but shell is shell