This is pipe separate data. First column represents dealer id and 4th column represents the zip code where dealer is located.
I am seeing a situation ,like above , where the numbers match and it creates a problem for me.
If i do a simple grep on '38999' , its bound to return me both rows whereas i am just looking for dealer id column.I do not want to filter data on zip code.
In above example , it should return me just the first row.
I guess 'awk' can help but i would like to understand if grep/fgrep can help here.Env is AIX 5.3.
I want to search the entire file [comprising of thousands of records] in unique way. It has to search based on first column only ,which is always going to be a dealer code i.e a number and should not return any rows where zip code matches with the dealer id...
Earlier while searching ,i knew what i was searching for and i can loop the solutions you provided over a file to extract all unique matching rows...
Now ,if i say , let's search the entire file based on its first column ,which is a number of unknown length.... Whatever is the length ,search has to look upto first occurance of '|' and must return the row. Here , there is no question of 'match found' since the search is solely based on first column.
I need to handle incorrect or garbage data here ; so i must search on first column ,if found ,direct it to a file else report an error.