1

(I know there's a similar post about this, but the solution given is not working for me as it only works for that case in particular.)

I have something like this (File1.txt):

digraph G {
1 [shape="oval" label= "Open"] 
... 
8->9 [style="dashed" label= "true"]
...
2 [shape="oval" label= "Close"] 
8->9 [style="dashed" label= "true"]
...
}

And I want a new file that looks like this (File.txt):

digraph G {
...
1 [shape="oval" label= "Open"]  
8->9 [style="dashed" label= "true"]
...
}

I tried using sort -u File1.txt >> File.txt but I don't want it sorted, I need it in the original order.

Thanks in advance

4
  • If you don't want it sorted, shuffle it. Commented May 14, 2012 at 18:03
  • @n.m. I think he wants the original order (cause that's the only thing that makes any sense) Commented May 14, 2012 at 18:04
  • That's it. I need it in the original order after removing the duplicates. Commented May 14, 2012 at 18:05
  • And how do you want 1 and 2 matched, just on shape="oval"? Commented May 14, 2012 at 18:12

1 Answer 1

1

You can do this without sorting with AWK:

awk '!x[$0]++' file > newfile
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.