Bash: replacing a substring in pipe stdin

后端 未结 2 1027
醉话见心
醉话见心 2021-02-07 12:54

I try to replace a certain substring from the stdin with a new substring. I have to get the stdin from the pipe, after reading several files by cat. Then I want to

2条回答
  •  一个人的身影
    2021-02-07 13:46

    With Parameter Expansion:

    cat file1 file2 | while read -r line; do echo "${line/@path_to_file/path\/to\/file}"; done
    

提交回复
热议问题