0
4

4 回答 4

1

是不是很简单:

while read i 
do
    sed s/XXXX/$i/ file1.txt
done < file2.txt > output

你在找什么?

于 2013-08-27T03:26:36.863 回答
0

又是一个 awk 命令:

awk 'BEGIN { while ((getline line < ARGV[1]) > 0) a[i++] = line; ARGV[1] = ""; } { for (i = 1; i in a; ++i) { t = a[i]; gsub(/XXXX/, $0, t); print t }; }' file1 file2

于 2013-08-27T07:21:14.620 回答
0
$ awk 'NR==FNR{r=r $0 ORS;next} {t=r; gsub(/XXXX/,$0,t); printf "%s",t}' file1 file2
Monday home
Tuesday home
home Wednesday
Thursday home
Monday school
Tuesday school
school Wednesday
Thursday school
Monday cinema
Tuesday cinema
cinema Wednesday
Thursday cinema
于 2013-08-28T03:26:37.570 回答
0

这可能对您有用(GNU sed):

sed 's|.*|sed s/XXXX/&/g file1|e' file2

这使用 GNU 特定e标志在 sed 命令中运行 sed 命令。

或者您可以将生成的 sed 命令通过管道传输到 shell:

sed 's|.*|sed s/XXXX/&/g file1|' file2 | sh
于 2013-08-27T06:31:53.163 回答