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

awk/sed reading line by line from a file and replace a substring in each line

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

你可以使用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