If I have a file with multiple lines and I want to sort it in reverse order by the number of login failures, how would I go about doing such when the Login Fails field is sometimes the 4th field and sometimes the 5th field?
Username Name Login Fails Flags Last Login
USER1 Joe Schmoe 1 DisPwdHis 30-OCT-2002
FTP Dennis A. Johnson 50 DisPwdHis 16-JAN-2003
I know that if they were all in the 4th field, then I could do a cat filename | sort -nr -k 4,4 | awk '{print $1, $2, $3, $4, $5, $6}'
How would I go about doing this if the field I want to sort by could be either the 4th or 5th field depending on the user's name.
Any help would be greatly appreciated.
Thanks,
John
Username Name Login Fails Flags Last Login
USER1 Joe Schmoe 1 DisPwdHis 30-OCT-2002
FTP Dennis A. Johnson 50 DisPwdHis 16-JAN-2003
I know that if they were all in the 4th field, then I could do a cat filename | sort -nr -k 4,4 | awk '{print $1, $2, $3, $4, $5, $6}'
How would I go about doing this if the field I want to sort by could be either the 4th or 5th field depending on the user's name.
Any help would be greatly appreciated.
Thanks,
John