Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieving Distinct text from a file

Status
Not open for further replies.
Oct 22, 2001
215
US
Would it be possible to read/retreave distinct values of a text from a text file?
MY file is:
ABCD12345
ABCD234
CDGX345
CSGX456

I am using cut command that is reading from 1st position to 4th position some thing like this:
cut -c1-4 my_text_file
This does retrieve all the rows but not distinct:
ABCD
ABCD
CDGX
CDGX
Is there a way to group by this text or get the distinct value of this text? TIA
 
Hi:

Pipe your cut to the uniq command:

cut -c1-4 my_text_file|uniq

Regards,


Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top