Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Dec 14, 2006, 08:06 AM   #1
Tinlad
macrumors member
 
Join Date: May 2006
Location: Nottingham, UK
Applescript or Terminal - String manipulation

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.
__________________
15" Unibody MacBook Pro 2.66GHz, 4GB RAM, 250GB 7200RPM.
80GB Silver iPod classic, 8GB iPod touch 2G (with Shure E2c 'phones)
Tinlad is offline   0 Reply With Quote
Old Dec 14, 2006, 09:24 AM   #2
robbieduncan
Moderator
 
robbieduncan's Avatar
 
Join Date: Jul 2002
Location: London
$NF in awk is always the last field, no matter how many fields there are.
robbieduncan is offline   0 Reply With Quote
Old Dec 14, 2006, 09:50 AM   #3
Tinlad
Thread Starter
macrumors member
 
Join Date: May 2006
Location: Nottingham, UK
Fantastic.

Thanks a lot!
__________________
15" Unibody MacBook Pro 2.66GHz, 4GB RAM, 250GB 7200RPM.
80GB Silver iPod classic, 8GB iPod touch 2G (with Shure E2c 'phones)
Tinlad is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Send Email Using Applescript or Terminal rebello95 OS X 2 Oct 21, 2011 03:27 PM
AppleScript to terminate application in xcode lynkynpark86 Mac Programming 0 Mar 29, 2010 08:58 AM
Applescripting my Terminal startups ltHank OS X 1 Nov 4, 2008 06:47 PM
Simple question about applescripting a terminal command sitryd Mac Programming 5 Nov 1, 2007 11:50 AM
Applescript vs. Terminal - Help needed twynne Mac Programming 5 Apr 21, 2006 04:55 PM


All times are GMT -5. The time now is 05:16 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC