Bash 在管线的每一行后面追加字符串
下面的script.bin通过T形行追加到file.log(来自我的bash脚本) 我的目标是在tee创建的每一行之后添加“IP=127.0.0.1” (以IP地址为例) 备注:我们无法修改script.bin以添加“IP=127.0.0.1”-因为它是二进制文件Bash 在管线的每一行后面追加字符串,bash,Bash,下面的script.bin通过T形行追加到file.log(来自我的bash脚本) 我的目标是在tee创建的每一行之后添加“IP=127.0.0.1” (以IP地址为例) 备注:我们无法修改script.bin以添加“IP=127.0.0.1”-因为它是二进制文件 我需要建议如何在file.log中创建的每一行之后添加IP=xxx.xxx.xxx.xxx 乔恩 首先用管道将其穿过sed,以ip替换管线末端 ./script.bin | sed 's/$/ IP=127.0.0.1/' | tee
我需要建议如何在file.log中创建的每一行之后添加IP=xxx.xxx.xxx.xxx 乔恩
首先用管道将其穿过sed,以ip替换管线末端
./script.bin | sed 's/$/ IP=127.0.0.1/' | tee...
我需要建议如何在file.log中创建的每一行之后添加IP=xxx.xxx.xxx.xxx
cat file.log (the ordinary file.log)
start_listen_to_port - 5500
start_listen_to_port - 5400
start_listen_to_port - 5410
.
.
.
cat file.log ( the right log.file syntax )
start_listen_to_port - 5500 IP=127.0.0.1
start_listen_to_port - 5400 IP=127.0.0.1
start_listen_to_port - 5410 IP=127.0.0.1
.
.
.
./script.bin | sed 's/$/ IP=127.0.0.1/' | tee...
./script.bin | sed "s/\$/ IP=$IP/" | tee -a file.log