Determine Computer name
My command ultimately is
$ cat /Library/Preferences/SystemConfiguration/preferences.plist|awk '/ComputerName/ {getline;print}'|awk -F'[<|>]' '/string/{print $3}'
mymacbookpro
Towards the bottom of preferences.plist is the computer name. It's in XML underneath the line containing ComputerName.
###
### Explanation
###
### Print the lines after any occurance of "ComputerName"
$ cat /Library/Preferences/SystemConfiguration/preferences.plist|awk '/ComputerName/ {getline;print}'
<string>mymacbookpro</string>
<integer>0</integer>
### Remove XML/HTML-ish tags, which also only prints the first instance (not sure why)
$ cat /Library/Preferences/SystemConfiguration/preferences.plist|awk '/ComputerName/ {getline;print}'|awk -F'[<|>]' '/string/{print $3}'
mymacbookpro
Message was edited by: ai4891
I was able to shorten it from the original but I still think there's room for improvement, any ideas?