user3467773
user3467773

Reputation: 39

I want read a file but ignore repeating lines. How to do that?

I am reading a text file from perl which is as follows:

    USA 1266222 John
    Russia 2212222 Jenny
    USA 1266222 John
    China 213111 Chian

I want to ignore repeating lines. How should i do that? In this case USA should just be shown once.

Upvotes: 1

Views: 43

Answers (1)

mpapec
mpapec

Reputation: 50647

perl -ane '$s{$F[0]}++ or print' file

Upvotes: 2

Related Questions