我有:
Location.txt(内容)
some_line1
some_line2
some_line3
region.txt(内容)
region1
region2
region3
uri.txt(内容)
/some_text/some_text1/***/
/some_text/***/some_text2/
/***/some_text/some_text3/
我需要创建文件
region1
region2
region3
他们每个人都必须填写以下内容(地区名称而不是星星)
文件 region1 示例
/some_text/some_text1/region1/
some_line1
some_line2
some_line3
/some_text/region1/some_text2
some_line1
some_line2
some_line3
/region1/some_text/some_text3
some_line1
some_line2
some_line3
文件 region2 示例(区域名称而不是星号)
/some_text/some_text1/region2/
some_line1
some_line2
some_line3
/some_text/region2/some_text2
some_line1
some_line2
some_line3
/region2/some_text/some_text3
some_line1
some_line2
some_line3
我现在有
#!/bin/bash
while read region
do
while read uri
do
echo $uri >> "/home/user/regions/$region"
done < uri.txt
done < region.txt
此脚本创建具有行名称的文件,region.txt
并用来自 的行填充它uri.txt
。
但是我必须制作很多文件。每个文件应填充多个位置,但每个位置中的一行应更改为 line from uri.txt
。
看起来我必须使用
cat $file|sed 's/^was/now/'
但我不知道如何使用它。
请提供任何帮助。