Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unix command primer, was Re: Report gathering-UGH



On Tue, 29 Mar 2005, Jerry Fess wrote:

> So, how can I find out the serial number of the computer via Unix
> command?

Use the 'system_profiler' command. Here's one way to do it:

    $ /usr/sbin/system_profiler -detailLevel 2 | grep 'Serial Number:'
          Serial Number: XB4091C1QES
              Serial Number: DBDL919610WL
                  Serial Number: 3JS2XGS7
    $

Note a couple of things though:

    * this command does a full system scan, so it's pretty slow

    * chances are you'll get more than one 'Serial Number:' line.

This second point is the annoying one. You probably only want the first
serial number; any others will be for other hardware or applications,
rather than for your system overall. Doing a `grep` with three lines of
context will show this more clearly:

    $ /usr/sbin/system_profiler -detailLevel 2 | grep -C3 'Serial Number:'
          Memory: 1 GB
          Bus Speed: 900 MHz
          Boot ROM Version: 5.1.5f0
          Serial Number: XB4091C1QES



    --
              Manufacturer: PIONEER
              Model: PIONEER DVD-RW DVR-106D
              Revision: A606
              Serial Number: DBDL919610WL
              Drive Type: CD-RW/DVD-RW
              Disc Burning: Apple Supported/Shipped
              Removable Media: Yes
    --
                  Capacity: 149.05 GB
                  Model: ST3160023AS
                  Revision: 3.05
                  Serial Number: 3JS2XGS7
                  Removable Media: No
                  Detachable Drive: No
                  BSD Name: disk0
    $

To just get the first one, add a `head -1` suffix to end up with this:

    $ /usr/sbin/system_profiler -detailLevel 2 | \
    > grep 'Serial Number:' | head -1
      Serial Number: XB4091C1QES
    $

And to just capture the third field from that, you can use `awk`:

    $ /usr/sbin/system_profiler -detailLevel 2 | \
    > grep 'Serial Number:' | head -1 | awk '{print $3}'
    XB4091C1QES
    $

Make sense?



-- 
Chris Devers    phone: 617.649.0716    aim: chdevers
jabber: chdevers    url: http://cesar.revahertz.com/

np: 'Day Tripper'
     by The Beatles
     from '1'
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Remote-desktop mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/remote-desktop/email@hidden

This email sent to email@hidden

References: 
 >Report gathering-UGH (From: Jerry Fess <email@hidden>)
 >Re: Report gathering-UGH (From: Chris Devers <email@hidden>)
 >Unix command primer, was Re: Report gathering-UGH (From: Chris Devers <email@hidden>)
 >Re: Unix command primer, was Re: Report gathering-UGH (From: Jerry Fess <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.