Get a Macs Serial Number from the Command Line
You can quickly retrieve any Macs serial number via the command line by using the following command string:
system_profiler |grep "r (system)"
The command results will look something like this:
$ system_profiler |grep "r (system)"
Serial Number (system): C24E1322XXXX
If you just grep for “Serial Number” you’ll be presented with serial numbers to other hardware included in the Mac, which is why the “r (system)” qualifier is included.
Once you have a serial number, you can do things like check AppleCare warranty status and repair history.

faster:
system_profiler SPHardwareDataType | grep “Serial”
Using “About this Mac” under the Apple menu us much easier. Click the line between Mac OS X and above the Software Update button (by default you’ll see the version number, first click shows the build number and the second click will show your Mac’s serial number.)
The solution described by this post’s title, and indeed the whole purpose, is to get the computer’s serial number via the COMMAND LINE. How many paint chips did you eat as a child, Squanto?
Lol @ one machine in my office i have this serial number:
SOMESRLNMBR
system_profiler SPHardwareDataType | awk ‘/Serial Number/ { print $4; }’
less to type and easier to remember
system_profiler | less
give the whole first page of system profile