我不熟悉使用' sed'。我有一个文件,其中有一些文字如下。
this is a test1
length 12
width 12
this is test2
length 50
width 50
我不确定multiline sed命令会是什么样子。我希望我的输出是
this is a test1
length 12
//width 12
new width 40
this is test2
length 50
width 50
答案 0 :(得分:0)
试试这个W20150925-00:14:05.787(-4)? (STDERR) throw e;
W20150925-00:14:05.787(-4)? (STDERR) ^
W20150925-00:14:05.789(-4)? (STDERR) Error: Channel ended, no reply will be forthcoming
W20150925-00:14:05.789(-4)? (STDERR) at rej (/Users/rkstar/dev/projects/wacoosta/.meteor/local/isopacks/npm-container/npm/node_modules/wascally/node_modules/amqplib/lib/channel.js:189:7)
W20150925-00:14:05.789(-4)? (STDERR) at Channel.C._rejectPending (/Users/rkstar/dev/projects/wacoosta/.meteor/local/isopacks/npm-container/npm/node_modules/wascally/node_modules/amqplib/lib/channel.js:195:42)
W20150925-00:14:05.789(-4)? (STDERR) at Channel.C.toClosed (/Users/rkstar/dev/projects/wacoosta/.meteor/local/isopacks/npm-container/npm/node_modules/wascally/node_modules/amqplib/lib/channel.js:159:8)
W20150925-00:14:05.789(-4)? (STDERR) at Channel.C.accept (/Users/rkstar/dev/projects/wacoosta/.meteor/local/isopacks/npm-container/npm/node_modules/wascally/node_modules/amqplib/lib/channel.js:405:10)
W20150925-00:14:05.789(-4)? (STDERR) at Connection.mainAccept [as accept] (/Users/rkstar/dev/projects/wacoosta/.meteor/local/isopacks/npm-container/npm/node_modules/wascally/node_modules/amqplib/lib/connection.js:62:33)
W20150925-00:14:05.789(-4)? (STDERR) at Socket.go (/Users/rkstar/dev/projects/wacoosta/.meteor/local/isopacks/npm-container/npm/node_modules/wascally/node_modules/amqplib/lib/connection.js:465:48)
W20150925-00:14:05.789(-4)? (STDERR) at Socket.emit (events.js:92:17)
W20150925-00:14:05.790(-4)? (STDERR) at emitReadable_ (_stream_readable.js:427:10)
W20150925-00:14:05.790(-4)? (STDERR) at emitReadable (_stream_readable.js:423:5)
W20150925-00:14:05.790(-4)? (STDERR) at readableAddChunk (_stream_readable.js:166:9)
命令。我希望这会对你有所帮助,
sed
<强>输出:强>
sed ':loop ; N ; /\n$/{s/.*/\/\/&new width 40\n/} ; t loop' FileName.txt
答案 1 :(得分:0)
这个命令可以帮到你。
sed 's:\(width 12\)://\1\nnew width 40:g'
o@o:~$ sed 's:\(width 12\)://\1\nnew width 40:g' se.file
this is a test1
length 12
//width 12
new width 40
this is test2
length 50
width 50