Hello All,
In our environment the Loggen in User name is in firstname.lastname format and I am trying to figure out how to extract the first name with a script. Till now what I have is below
#!/bin/bash
#gets current logged in user
getUser=$(ls -l /dev/console | awk '{ print $3 }')
Echo $getUser
#gets named
firstName=$(finger -s $getUser | head -2 | tail -n1 | awk '{print toupper($2)}')
computerName="ABCD-ABM-"$firstName"-MacBook"
Echo $computerName
#set all the name in all the places
scutil --set ComputerName "$computerName"
scutil --set LocalHostName "$computerName"
scutil --set HostName "$computerName"
sudo Jamf recon
And the result I am getting is -
ABCD-ABM-LASTNAME-MacBook
I am not good with scripting however what I understand is the 'firstName' is unable to fetch first name from firstname.lastname however same works good when the name is like firstname lastname.