Adding Characters to a Word List

If I had a word list with a large amount of words in it, how would I (using a unix command) add, say, 123 to the end of each word?

EDIT: The word list is stored in a large text file. I need a command that applies the ending to each word in the file and saves the result in a new text file.

Something like

$ echo 'myword1 myword2 myword3' | sed 's/\([ ]\{0,1\}.[^ ]*\)/\1123/g'
myword1123 myword2123 myword3123
$ 

:confused:

Another one:

echo a b c d | 
awk '$NF=$NF "123"' OFS="123 " 
1 Like

Hmm thats great, but is there one command that would obtain text from a text file with the word list in it, apply the ending, then save a new text file?

echo 'myword1 myword2 myword3' | sed 's/[^ ][^ ]*/&123/g'
sed 's/\([ ]\{0,1\}.[^ ]*\)/\1123/g' wordlistfile > newfile
awk '$NF=$NF "123"' OFS="123 " list > new_file
1 Like

Thanks Franklin52!

---------- Post updated at 01:53 PM ---------- Previous update was at 01:35 PM ----------

Your code worked for a small list, but when trying a big list it put "123" on the next line, instead of attached to a word:

Word
123
Word
123
...

Instead of

Word123
Word123
...

Any thoughts?