【发布时间】:2014-10-01 00:39:38
【问题描述】:
我有一个场景,我需要用该文件名替换目录内多个文件中的变量(同一个变量)。
例如,我有一个内容相同的文件列表;
文件1 文件2 文件 3 文件4
每个文件的内容是;
Some Text
Another line of text
I need to replace this $variable
我想做的是将模式 $variable 的所有实例替换为所述文件的名称。
即file1 的内容会变成
Some Text
Another line of text
I need to replace this file1
file2的内容会变成
Some Text
Another line of text
I need to replace this file2
我一直在研究 sed,并认为这可能是要走的路,但我在脚本编写方面经常出错,这当然不是一个强项。
【问题讨论】:
标签: bash shell sed scripting find