Reputation: 31
My file contains some urls in urls.txt Another file contains some different words in words.txt
I need to be add every word at the end of the every url.
I want output like (line by line)
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
I just want single line command :)
like
urls.txt + words.txt >> output.txt
Upvotes: 0
Views: 80
Reputation: 104072
Given:
cat words.txt
hi
hello
there
cat urls.txt
url.1
url.2
url.3
You can use awk
this way:
awk 'FNR==NR{words[++cnt]=$1; next}
{for (i=1; i<=cnt; i++) print $1 words[i]}
' words.txt urls.txt
Prints:
url.1hi
url.1hello
url.1there
url.2hi
url.2hello
url.2there
url.3hi
url.3hello
url.3there
Upvotes: 2
Reputation: 58508
This might work for you (GNU sed & Parallel)
parallel echo "{1}{2}" :::: urlsFile :::: wordsFile
or
sed 's@.*@echo "&" | sed "s#.*#&\&#" wordsFile@e' urlsFile
Upvotes: 1