Parse txt file for string and return whole line

Hello.
I’m trying to write an applescript to pars a text file for “Serial Number:” and return what comes after it…the actual serial number.

The files are output from a sysadmin retrieving information from HDDs in disk arrays. I need the serial numbers for inventory tracking.

I know this is simple but I’m scripting-challenged :slight_smile:

Sample text from file:

    Submodel ID:               6                             
     Product ID:                CSM200_R                      
     Product revision:          0710                          
     Serial number:             XXXXXXXXXX                    
     Date of manufacture:       March 16, 2007      

Expected result in new text file:

xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx

Thanks,
Ken

Model: MBP Pro
AppleScript: 2.1.1
Browser: Safari 531.21.10
Operating System: Mac OS X (10.6)

Hi,

this is one of several ways


set theText to "Submodel ID:               6                             
         Product ID:                CSM200_R                      
         Product revision:          0710                          
         Serial number:             XXXXXXXXXX                    
         Date of manufacture:       March 16, 2007      
"
set serialNumber to do shell script "/bin/echo -n " & quoted form of theText & " | /usr/bin/awk '/Serial number/ {print $NF}'"