I have a bash script reading names from a webpage as variables, which use the format LASTNAME Firstname:
SANCHEZ Rick
SMITH Morty
VAN SOMETHING Halen
However, I need to display each name as Firstname LASTNAME:
Rick SANCHEZ
Morty SMITH
Halen VAN SOMETHING
I am looking for a way to recognize the lowercase capitalised first name and put it before the uppercase last name or names.
The closest I got was
echo $eachname | awk '{ for (i=NF; i>1; i--) printf("%s ",$i); print $1; }'
This command however messes up people with two last names:
Rick SANCHEZ
Morty SMITH
Halen SOMETHING VAN