早教吧 育儿知识 作业答案 考试题库 百科 知识分享

高分虚心求教编辑一个脚本,使用sed提取指定行中匹配的内容,并按照指定格式输出文本.[root@server1]#vim/tmp/test.txtTrying192.168.0.7...^MConnectedto192.168.0.7.^MEscapecharacteris'^]'.^M1、首先提取从.这

题目详情
高分虚心求教编辑一个脚本,使用sed提取指定行中匹配的内容,并按照指定格式输出文本.
[root@server1 ]# vim /tmp/test.txt
Trying 192.168.0.7...^M
Connected to 192.168.0.7.^M
Escape character is '^]'.^M
1、首先提取从.这一行中,提取含有" "中的内容.
2、然后各行输出user online=" " ,login=" ",player count=" ",memory used=" ",free=" " ,total=" " 至mail.txt文本中.
▼优质解答
答案和解析
grep -oP '((user online|login|player count|memory used|free|total)="([0-9]*)")' test.txt > mail.txt