View Full Version : Applescript or Terminal - String manipulation

Dec 14, 2006, 08:06 AM
Hi, I've got a bit of a mental block.

I'm writing a script for Salling Clicker using AppleScript that will allow me to mount/unmount the partitions on my external drive remotely.

At the moment I have the name of the partition I want to unmount, "Mac Files", but I need the identifier, "disk1s1", which is the last six characters of the output from a shell script it runs:

1: Apple_HFS Mac Files 162.9 GB disk1s1

How can I use either AppleScript or some bash command to get those last six characters only? Using awk '{print $6}' to print only the sixth field only works if the partition doesn't have a space in the name.

I hope that makes sense. Thanks in advance.

Dec 14, 2006, 09:24 AM
$NF in awk is always the last field, no matter how many fields there are.

Dec 14, 2006, 09:50 AM

Thanks a lot!