Skip to main content
use `sed` arguments that work with both GNU and BSD versions
Source Link
DopeGhoti
  • 79.2k
  • 10
  • 107
  • 141

From my earlier comment to the question itself:

egrep '^(pro|con).* /usr/share/dict/words | sed -nrnE 's/^(pro|con)(.*)/\2/p' | sort | uniq -d 

will give you a list of all the word-bases that have both a pro and con prefix:

The initial egrep grabs all the words with pro and con prefixes. We then use sed to strip off pro and con from the beginning of each word, sort the list, and then use uniq -d to show ony entries on the list that have duplicates.

From my earlier comment to the question itself:

egrep '^(pro|con).* /usr/share/dict/words | sed -nr 's/^(pro|con)(.*)/\2/p' | sort | uniq -d 

will give you a list of all the word-bases that have both a pro and con prefix:

The initial egrep grabs all the words with pro and con prefixes. We then use sed to strip off pro and con from the beginning of each word, sort the list, and then use uniq -d to show ony entries on the list that have duplicates.

From my earlier comment to the question itself:

egrep '^(pro|con).* /usr/share/dict/words | sed -nE 's/^(pro|con)(.*)/\2/p' | sort | uniq -d 

will give you a list of all the word-bases that have both a pro and con prefix:

The initial egrep grabs all the words with pro and con prefixes. We then use sed to strip off pro and con from the beginning of each word, sort the list, and then use uniq -d to show ony entries on the list that have duplicates.

Better use of sed so as not to `sed | grep`
Source Link
DopeGhoti
  • 79.2k
  • 10
  • 107
  • 141

From my earlier comment to the question itself:

egrep '^(pro|con).* /usr/share/dict/words | sed -nr 's/^pro//;s/^con^(pro|con)(.*)/\2/'p' | sort | uniq -d 

will give you a list of all the word-bases that have both a pro and con prefix:

The initial egrep grabs all the words with pro and con prefixes. We then use sed to strip off pro and con from the beginning of each word, sort the list, and then use uniq -d to show ony entries on the list that have duplicates.

From my earlier comment to the question itself:

egrep '^(pro|con).* /usr/share/dict/words | sed 's/^pro//;s/^con//' | sort | uniq -d 

will give you a list of all the word-bases that have both a pro and con prefix:

The initial egrep grabs all the words with pro and con prefixes. We then use sed to strip off pro and con from the beginning of each word, sort the list, and then use uniq -d to show ony entries on the list that have duplicates.

From my earlier comment to the question itself:

egrep '^(pro|con).* /usr/share/dict/words | sed -nr 's/^(pro|con)(.*)/\2/p' | sort | uniq -d 

will give you a list of all the word-bases that have both a pro and con prefix:

The initial egrep grabs all the words with pro and con prefixes. We then use sed to strip off pro and con from the beginning of each word, sort the list, and then use uniq -d to show ony entries on the list that have duplicates.

Expand `sed` command to be a little more obvious
Source Link
DopeGhoti
  • 79.2k
  • 10
  • 107
  • 141

From my earlier comment to the question itself:

egrep '^(pro|con).* /usr/share/dict/words | sed 's/^...^pro//;s/^con//' | sort | uniq -d 

will give you a list of all the word-bases that have both a pro and con prefix:

The initial egrep grabs all the words with pro and con prefixes. We then use sed to strip off pro and con from the first three charactersbeginning of each word, sort the list, and then use uniq -d to show ony entries on the list that have duplicates.

From my earlier comment to the question itself:

egrep '^(pro|con).* /usr/share/dict/words | sed 's/^...//' | sort | uniq -d 

will give you a list of all the word-bases that have both a pro and con prefix:

The initial egrep grabs all the words with pro and con prefixes. We then use sed to strip off the first three characters of each word, sort the list, and then use uniq -d to show ony entries on the list that have duplicates.

From my earlier comment to the question itself:

egrep '^(pro|con).* /usr/share/dict/words | sed 's/^pro//;s/^con//' | sort | uniq -d 

will give you a list of all the word-bases that have both a pro and con prefix:

The initial egrep grabs all the words with pro and con prefixes. We then use sed to strip off pro and con from the beginning of each word, sort the list, and then use uniq -d to show ony entries on the list that have duplicates.

Source Link
DopeGhoti
  • 79.2k
  • 10
  • 107
  • 141
Loading