Perl – How to print only certain fields in a space separated file

fieldperlsplit

I have a file containing the following content 1000 line in the following format:

abc def ghi gkl

How can I write a Perl script to print only the first and the third fields?

abc ghi

Best Answer

perl -lane 'print "@F[0,2]"' file