No creation dates from stat
Posted: February 22, 2008 Filed under: Mac OS X, Scripting, Unix | Tags: applescript, GetFileInfo, resource fork, stat Leave a comment »I was surprised to learn that creation dates are not included in stat output. I really thought stat would include something so basic. You get time of last access, time of last data modification, and time of last file status change, but creation date isn’t in there.
On the Mac, this info is stored in the resource fork. You can get it from the command line using GetFileInfo which is installed when you install Apple’s free Developer Tools.
/Developer/Tools/GetFileInfo -d path/to/file
In Applescript you can use info for:
creation date of (info for (choose file))
Bootable Software RAID 0+1, 1+0 in Mac OS X
Posted: February 17, 2008 Filed under: Uncategorized | Tags: diskutil, DiskUtility, mirror, mirrored stripe, nested RAID, software raid, stripe, striped mirror 1 Comment »Software RAID striped mirrors or mirrored stripes are possible in Mac OS X. They may be 10.5 only. I haven’t tested other versions.
Simply create your striped sets using DiskUtility or diskutil, then use the command line diskutil and supply the /dev/diskx entries of the stripe sets when creating your mirror.
First run diskutil list to get the /dev/disk entries for each stripe, then create your mirror using:
diskutil createRAID mirror MirrorName JHFS+ disk1 disk2
where disk1 is the device for the first stripe set and disk2 is the device for the second stripe set.
The result is also bootable and will display correctly as a nested RAID in DiskUtility.app.
convert lines to comma separated items with tr
Posted: February 4, 2008 Filed under: Scripting, Unix | Tags: comma separated, convert, device list, diskutil, grep, new lines, regex, Scripting, sed, tr, Unix Leave a comment »If you have output that is separated by new lines, but you really want it formatted into a single line with commas as separators or maybe a space as a separator, just pipe to tr.
Here is a simple example:
kserver:~ patternbuffer$ diskutil list | grep ^/dev
/dev/disk0
/dev/disk1
If we want them separated by spaces, we could do:
kserver:~ patternbuffer$ diskutil list | grep ^/dev | tr '\n' ' '
/dev/disk0 /dev/disk1
Note that there is a newline on the end of the output, so that trailing newline is also translated. So if you don’t want it there, you’ll have to chomp it off. I use sed, but use what you like.
Here is the same as above, but with commas, with sed to remove the trailing comma.
kserver:~ patternbuffer$ diskutil list | grep ^/dev | tr '\n' ',' | sed 's/.$//'
/dev/disk0,/dev/disk1