I have a file lets say input.csv having two columns like-
Name,Mobile No
A,111
B,222
A,333
A,123
B,213
I would like to find result in a new file lets say output.csv as-
Name,Mobile No
A,111
B,222
means short the file on the basis of first column and first value corresponding to the unique one of first column from second one.
Any help should be highly appreciated..... Plz help me I m a new in shell
sort -t, -k1,1 -u input.csv
1 Like
cat input.csv | awk -F"|" '{ if (NR == 1 || NR == 2) print $0' >> output_file_name
Assuming you want to capture first two lines
1 Like
Thanks for quick response but i don't want only first two lines. I like to find unique values from column one and their corresponding values from column 2 from a input csv file.
Have you tried the sort command which I have provided above?
1 Like
ripat
July 23, 2013, 5:39am
6
Useless use of cat and awk instead of head.
1 Like