Friday, March 25, 2011

OS X boots to grey screen with spinning disc

Recent went through a scenario where I was turning a MacBook Pro into a fashionable brick. Install OS, completely update, apply a bunch of new settings & software, reboot, and fu.... Grey screen with spinning disc. I'd diligently boot into my install DVD, repair disk(saw errors about file and directory counts and fix them), repair permission, reboot, and fu... Repeat process. I finally figured out that /System/Library/LaunchDaemons will read every file in that directory upon boot, even if it doesn't end with .plist. I didn't want to fubar any of the files in that directory so I would create a backup copy of the file I was working with and would save them in that directory and end the file with .ORIG Turns out that upon boot both files were bumping into each other and the machine would not boot. Finally moved my backup file into /Users/Shared and the machine boots. So don't keep backup copies of files in /System/Library/LaunchDaemons, store them somewhere else.

Thursday, March 17, 2011

Bash substrings

Say you have lines in a file that are of the format:


and you need to split out the strings to work with them.

string2=${string:0:3} # result is 123
string3=${string:4:6} # result is 201004