Hi,
A text file contains lines of fields seperated by some delimiter; space for example; some lines but not all will have in the second field a value like an inital (e.g., A. or B. or Jr.) for those lines with such a value in field 2, we wish to have that value deleted. We also wish to do this as a one-liner. Here's what we have so far, but this omits all the other lines without a period in any field. What say you?
perl -i.bak -ane "print unless $F[2] =~ m{ \A (?: [[:alpha:]] | Jr) \. \z }xms" in.file
The following lines illustrate the issue:
Thomas, A. Alexandria S. Perl Programmer Las Vegas NV.
Williams, Jr., Michael A. C Programmer New York N.Y.
Silver, Susan Java Programmer San Jose CA
Altips, Alvin C. Tcl Programmer Chicago IL.
The challenge is to remove the A. and Jr., from the first two records, leaving the remaining fields in all lines with periods intact, and moreover leaving all other lines in the in.file. Thank you.