Issue
I would like to extract the first part of this hostname testsrv1
from testsrv1.main.corp.loc.domain.com
in UNIX, within a shell script.
What command can I use? It would be anything before the first period .
Solution
You can use cut
:
echo "testsrv1.main.corp.loc.domain.com" | cut -d"." -f1
Answered By - Pablo Santa Cruz Answer Checked By - Marilyn (WPSolving Volunteer)