Suppose I have a file similar to the following:
hello
hello
hi
hi
hello
hey
I would like to find the indices of every unique line and using a comma as the indices separator. So ideally, the output would be like:
hello 1,2,5
hi 3,4
hey 6
What has been done in getting the value of lines by using the following codes,
{ arr[$0]++ }
END { for (i in arr) {
print i
}
}
the result is,
hey
hi
hello