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

Similar Threads
thread Thread Starter Forum Replies Last Post
String and variable concatenation in AppleScript tekboi Mac Programming 6 Apr 15, 2014 01:37 PM
Match string against regex or character class in Applescript urello Mac Programming 0 Mar 7, 2014 06:11 AM
String chars to ASCII decimals inside terminal hakonandersson Mac Programming 14 Jun 16, 2013 11:11 AM
Basic string manipulation nashyo iPhone/iPad Programming 2 Jan 13, 2013 08:04 AM
Best spreadsheet/DB for text manipulation, AppleScript macmesser Mac Applications and Mac App Store 2 Dec 2, 2012 10:10 AM

Forum Jump

All times are GMT -5. The time now is 11:32 AM.

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

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