• 欢迎光临~

linux中sed如何替换换行符 top -p `ps aux | grep "Ali" | egrep -v "grep|PID" | awk -F'[ ]+' '{print $2}'|sed ":a;N;s/n/,/g;ta" `

开发技术 开发技术 2022-07-22 次浏览

top -p `ps aux | grep "Ali" | egrep -v "grep|PID" | awk -F'[ ]+' '{print $2}'|sed ":a;N;s/n/,/g;ta" `

第一种方法:使用test跳转命令,实现替换换行符

N是把下一行加入到当前的hold space模式空间里,使之进行后续处理,最后sed会默认打印hold space模式空间里的内容。也就是说,sed是可以处理多行数据的。

:a和ta是配套使用,实现跳转功能。t是test测试的意思。

另外,还有:a和ba的配套使用方式,也可以实现跳转功能。b是branch分支的意思。

branch和test区别

est可以根据替换命令的完成是否成功,决定是否跳转。比如sed ":a;N;s/n//g;ta" a.txt,
TRANSLATE with linux中sed如何替换换行符  top -p `ps aux | grep "Ali" | egrep -v "grep|PID" | awk -F'[ ]+' '{print $2}'|sed ":a;N;s/n/,/g;ta" ` x
English
Arabic Hebrew Polish
Bulgarian Hindi Portuguese
Catalan Hmong Daw Romanian
Chinese Simplified Hungarian Russian
Chinese Traditional Indonesian Slovak
Czech Italian Slovenian
Danish Japanese Spanish
Dutch Klingon Swedish
English Korean Thai
Estonian Latvian Turkish
Finnish Lithuanian Ukrainian
French Malay Urdu
German Maltese Vietnamese
Greek Norwegian Welsh
Haitian Creole Persian  
linux中sed如何替换换行符  top -p `ps aux | grep "Ali" | egrep -v "grep|PID" | awk -F'[ ]+' '{print $2}'|sed ":a;N;s/n/,/g;ta" `
linux中sed如何替换换行符  top -p `ps aux | grep "Ali" | egrep -v "grep|PID" | awk -F'[ ]+' '{print $2}'|sed ":a;N;s/n/,/g;ta" ` linux中sed如何替换换行符  top -p `ps aux | grep "Ali" | egrep -v "grep|PID" | awk -F'[ ]+' '{print $2}'|sed ":a;N;s/n/,/g;ta" ` linux中sed如何替换换行符  top -p `ps aux | grep "Ali" | egrep -v "grep|PID" | awk -F'[ ]+' '{print $2}'|sed ":a;N;s/n/,/g;ta" `
 
TRANSLATE with linux中sed如何替换换行符  top -p `ps aux | grep "Ali" | egrep -v "grep|PID" | awk -F'[ ]+' '{print $2}'|sed ":a;N;s/n/,/g;ta" `
COPY THE URL BELOW
linux中sed如何替换换行符  top -p `ps aux | grep "Ali" | egrep -v "grep|PID" | awk -F'[ ]+' '{print $2}'|sed ":a;N;s/n/,/g;ta" `
linux中sed如何替换换行符  top -p `ps aux | grep "Ali" | egrep -v "grep|PID" | awk -F'[ ]+' '{print $2}'|sed ":a;N;s/n/,/g;ta" ` Back
EMBED THE SNIPPET BELOW IN YOUR SITE linux中sed如何替换换行符  top -p `ps aux | grep "Ali" | egrep -v "grep|PID" | awk -F'[ ]+' '{print $2}'|sed ":a;N;s/n/,/g;ta" `
Enable collaborative features and customize widget: Bing Webmaster Portal
Back
喜欢 (0)