如何在每一行的末尾添加每个单词?字和行在不同的txt文件中

How to add every word at the end of the every line ? word and lines are in different txt file

我的文件在 urls.txt 中包含一些 url 另一个文件在 words.txt

中包含一些不同的词

我需要在每个 url 的末尾添加每个单词。

我想要这样的输出(逐行)

url.1/hi
url.1/hello
url.1/there
url.2/hi
url.2/hello
url.2/there
url.3/hi
url.3/hello
url.3/there

我只想要单行命令:)

喜欢

urls.txt + words.txt >> output.txt

鉴于:

cat words.txt
hi
hello
there

cat urls.txt
url.1
url.2
url.3

您可以这样使用awk

awk 'FNR==NR{words[++cnt]=; next}
    {for (i=1; i<=cnt; i++) print  words[i]}
' words.txt urls.txt

打印:

url.1hi
url.1hello
url.1there
url.2hi
url.2hello
url.2there
url.3hi
url.3hello
url.3there

这可能适合您(GNU sed 和并行)

parallel echo "{1}{2}" :::: urlsFile :::: wordsFile

sed 's@.*@echo "&" | sed "s#.*#&\&#" wordsFile@e' urlsFile