4
4
One of most common typos is to repeat the same word twice, as as here. I need an automatic procedure to remove all the repeated words in a text file. This should not be a strange feature for a modern editor or spell-checker, for example I remember that MS Word introduced this feature several years ago! Apparently, the default spell-check on my OS (hun-spell) can't do this, as it only finds words not in the dictionary.
It would be OK to have a solution valid for a specific text editor editor for linux (pluma/gedit2 or Sublime-text) and a solution based on a bash script.
1Is perl an acceptable alternative to bash? Because that'd be my first port of call. – Sobrique – 2014-11-22T23:01:31.927
@Sobrique Please, feel free to add it! I would favor bash-based answers though – altroware – 2014-11-23T01:13:07.370
You asked for a script to remove repeated words but you accepted an answer that just prints them and only recognizes even repetitions (it'd fail on
abc foo foo foo def
for example). If you still need to know how to do what you originally asked for then please do post a new question and tag it withawk
. – Ed Morton – 2020-02-09T14:53:01.443@EdMorton I’m actually happy with the solution, I still use it to find words repeated twice in a line. – altroware – 2020-02-09T15:09:48.053
sounds good, if you ever need more than that, just ask again and tag with awk. – Ed Morton – 2020-02-09T15:29:05.763