Question: My data table looks like that:

```
chr4    124097568       124098568       337
chr4    159597106       159598106       1000   
chr4    159597106       159598106       1000 
chr4    164361532       164362532       455
chr4    164361532       164362532       74
chr4    164361532       164362532       2
chr4    170360150       170361150       0

```

I want to: Extract unique rows - if data in col#2 & col#3 is the same -> just the highest value (col#4) row should be extracted. If #2,#3 & #4 are identical just one of the rows should be extracted. 

Preferred output is:

```
chr4    124097568       124098568       337
chr4    159597106       159598106       1000 
chr4    164361532       164362532       455
chr4    170360150       170361150       0

```

If something is not clear I'll try to explain it more (cause I really need to solve this problem now).

Answer: 
That would be easier if the last column (COL#4) was "right space padded", like this:

```
chr4    124097568       124098568        337
chr4    159597106       159598106       1000   
chr4    159597106       159598106       1000 
chr4    164361532       164362532        455
chr4    164361532       164362532         74
chr4    164361532       164362532          2
chr4    170360150       170361150          0

```

That way, a combination of sort and uniq could do the trick.
one possible solution is to sort the lines of your input and then kill the lines
which occur multiple times. In Python, you could do something like

```
f = open("table.dat", "r")
lines = f.read().split()
lines.sort()

old = lines[0]
singles = [old]
for line in lines:
    if old != line:
        singles.append(line)
        old = line
    else:
        pass

f.close()

```

I am unaware of how to do this in bash.

Best regards,
Sven