I am trying to isolate a username that contains spaces
my input is like :
username fullname
---------------------------------------------
SYSTEM SYSTEM
quarantine quarantine
nigel Nigel Hope
glennrosegarden Glenn Rose-garden
Rachel Sharpe Rachel Sharpe
Sue Purkins Sue Purkins
Anthony Anthony Loft
Stephanie Crooke Stephanie Crooke
Hannah Northern Hannah Northern
Darren Maynot Darren Maynot
Pauline E Dawson Pauline E. Dawson
Simon Parkin Simon Parkin
I am using
awk 'BEGIN {FS= " ";} {print $1}'
to try and isolate the first field
but it dosent work - any ideas ????
---------- Post updated at 09:04 AM ---------- Previous update was at 09:01 AM ----------
ugh this forum strips out the whitespace between the fields !!!
This code will give output as below
SYSTEM SYSTEM
quarantine quarantine
nigel Nigel
glennrosegarden Glenn
Rachel Sharpe
Sue Purkins
Anthony Anthony
Stephanie Crooke
Hannah Northern
Darren Maynot
Assigning two spaces to FS should work.
You may try this workaround though (convert all space to underscore, or any other unique character, assign this 2 new unique characters to FS, get the 1st field and convert unique character back to space)
sed 's/ /_/g' inputFile | awk 'BEGIN{FS="__"}{print $1}' | sed 's/_/ /g'
Did you try cabrao's command. That is looking for position where 2 spaces are there and deleting everything that position onwards. So output should be all characters before 2 spaces starts.
If it doesn't work, pls try following (check if there is some non-printable garbage character in file)
Please post what you get
that would be an elegant solution - however I have no idea of any of the tables behind it - the input is generated by our email system from the command