Issue
Is there a way in Unix to filter only Initials from a file that contains other texts too. Is it practical? (Apologize my poor wording)
input file
13 J JOHN
30 J
56 JACOB
29 JAKE
89 A
20 ALEX
12 A ARIEL
80 Z
34 Z ACK
67 K
Output:
30 J
89 A
80 Z
67 K
Solution
For the initial case (that no longer matches the question):
$ awk 'length($2) == 1' file
30 J
89 A
80 Z
67 K
EDIT: For the updated case:
$ cat file2
13 J JOHN
30 J
56 JACOB
29 JAKE
89 A
20 ALEX
12 A ARIEL
80 Z
34 Z ACK
67 K
$ awk 'NF == 2 && length($2) == 1' file2
30 J
89 A
80 Z
67 K
Answered By - jas Answer Checked By - Candace Johnson (WPSolving Volunteer)