I have a file with words, one word per line, which I now want to change so that is becomes a .sh-file with an egrep-search string for each word. The search string I want in the end looks like this:
`egrep -wi '\|WORD\.\.nn' stats_all.txt > WORD_frekvens.txt`
My word file looks like this:
$ more -10 word_file.txt anakonda ord tröja bord glas pension larm risk försening rapport
I have tried to do this with the following string:
sed -e 's/\(.*\)/egrep -wi '\''\\|\1\\.\\.nn'\'' stats_all.txt > \1_frekvens.txt/' word_file.txt | more
But it gives the output:
_frekvens.txt_all.txt > WORD
Why doesn't it work to use the
\1 here? It seems to be this part that's the problem, as it works if I exchange it for a word.
Anything I write after
\1 ends up writing over the content of
\1, i.e. "WORD". If I write something only before
\1 it works fine.
Very grateful for any help.