Hoa
Hoa

Reputation: 20438

Is there a way to use uniq to compare only the first n characters?

According to the documentation,

http://www.computerhope.com/unix/uuniq.htm

The command can be used to ignore the first n characters

Suppose I wish to have the following

03/08/2002,2,HUST,RICC,53.0,,2.3,J S BULLARD,,2,2,3/3,46.0,,,
03/08/2002,2,HUST,RICC,53.0,,WON,M J WALKER,,10,1,2/2,49.5,,,

Matched as identical based on the first 20 characters. Is there a way to do this?

Upvotes: 4

Views: 4555

Answers (1)

cnicutar
cnicutar

Reputation: 182649

My uniq manual (coreutils 8.5) says:

-w, --check-chars=N
compare no more than N characters in lines

This however isn't standard (thus won't work on other Unixes).

Upvotes: 10

Related Questions