I have a file which contains a 1000 lines. On each line i have multiple occurrences ( 26 to be exact ) of pattern folder#/folder#.
# is depicting the line number in the file
some text here folder1/folder1 some text here folder1/folder1 some text here folder1/folder1 some text here
some text here folder2/folder2 some text here folder2/folder2 some text here folder2/folder2 some text here
some text here folder3/folder3 some text here folder3/folder3 some text here folder3/folder3 some text here
.... up to line 1000
I'm trying to remove the duplicate occurrences so i can end up with the following:
some text here folder1/ some text here folder1/ some text here folder1/ some text here
some text here folder2/ some text here folder2/ some text here folder2/ some text here
some text here folder3/ some text here folder3/ some text here folder3/ some text here
.... up to line 1000
Could you please try following and let me know if this helps.
i- If your complete data is as same as you have shown, means each line has it's same LINE with line number and not more thn 4 fields in Input_file then following may help.
2nd: If you may have different data like different LINE numbers. number of columns(But considering that columns which have LINE string willhave only 2 columns serated by / ) may vary than following may help you in same.
Thanks very much. Your solution does work. Unfortunately i did not describe my issue more clearly so it did not work for my problem. I have updated the question with more clarification.
So basically on each line i have a whole bunch of different text, and within each line of text i have 26 occurrences of folder#/folder# at various places between the text. I just need the duplicate removed.
I could see my 2nd code works in POST#2, following is the code for same.
Let's say we have following Input_file:
some text here folder1/folder1 some text here folder1/folder1 some text here folder1/folder1 some text here
some text here folder2/folder2 some text here folder2/folder2 some text here folder2/folder2 some text here
some text here folder3/folder3 some text here folder3/folder3 some text here folder3/folder3 some text here
some text here folder1/ some text here folder1/ some text here folder1/ some text here
some text here folder2/ some text here folder2/ some text here folder2/ some text here
some text here folder3/ some text here folder3/ some text here folder3/ some text here
some text here folder1/ some text here folder1/ some text here folder1/ some text here
some text here folder2/ some text here folder2/ some text here folder2/ some text here
some text here folder3/ some text here folder3/ some text here folder3/ some text here