awk / sed从文件中逐行读取并替换每行中的子字符串

时间:2015-03-19 23:56:15

标签: awk sed

while read line
do
//Each line is a file name
//After reading each line i want to replace substring .json with .jpeg and use it in the below cp command.
 cp /mnt/ftp/xml/dd/ingest/new/processed/$line /mnt/ftp/xml/dd/ingest/JnJ-redo1
done < error_files.txt

1 个答案:

答案 0 :(得分:1)

您可以使用Shell Parameter Expansion在此处执行操作。

while read line
do
    cp /mnt/ftp/xml/dd/ingest/new/processed/"${line/.json/.jpeg}" /mnt/ftp/xml/dd/ingest/JnJ-redo1
done < error_files.txt