我有一个文件,其中包含多个lines.Here示例
etc/list.txt
MLA1234,MLA2345
MLA1235,MLA2345我需要在文件夹中搜索递归,搜索这个字符串和remplace。示例
etc/json/other/file2.json
{id:"MLA1234" , product_name:"blablabla"取代string MLA1234的预期前哨
etc/json/其他/file2.json(最终)
{id:"MLA2345" , product_name:"blablabla"我做了这样的事,但没有对手
#!/bin/bash
csvfile='list.txt'
# Make sure the file exists
if [ ! -f $csvfile ]
then
echo "ERROR: file $csvfile does not exist."
exit 1
fi
# Read the input file line per line
while read line
do
# Capture the information out of the line, fields separated by ;
IFS=',' read old new <<< $line
grep -rl $old . | xargs sed -i "s/$oldstring/$new/g"发布于 2020-03-25 16:12:50
他为我工作!我修好密码了!
#!/bin/bash
csvfile='list.txt'
# Make sure the file exists
if [ ! -f $csvfile ]
then
echo "ERROR: file $csvfile does not exist."
exit 1
fi
# Read the input file line per line
sed '1d' $csvfile | while read line
do
# Capture the information out of the line, fields separated by ;
IFS=',' read new old <<< $line
grep -rl "$old" . | xargs sed -i "s/$old/$new/g"
done```https://stackoverflow.com/questions/60850563
复制相似问题