In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to talk to you about the common usage of Sed, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following content for you. I hope you can get something from this article.
Replace all root in the file with abc:
Sed's Rot _ passwd ABCC _ G 'output only the execution result and does not modify the file.
Sed-I's _
Line 2 of the print file:
Sed-n 2p passwd
Print lines 2-5
Sed-n 2pm 5p passwd
Insert a line after line 2 of the file
Sed'2a 106, dandanje Caso 'passwd
Insert a line before the second line of the file
Sed'2i 106, dandan, Caso 'passwd.
Delete lines 2 to 5 from the file
Sed '2pm 5d' passwd
Implement to fetch the line matching begin until the end of the line matching to the end character
Sed-n'/ begin/,/end/p' 1.txt
Print the line that matches the abc to the last line
Sed-n'/ abc/,$p' file.txt
Intercept logs from six days ago
Sed-n'/'"$(date-d"-6 day "+% b"d)"'/, $p' / home/oracle/test/alert_orcl11g.log | more
Sed-n'/'"$(date-d"-6 day "+% b"d)"'/, $p' / home/oracle/test/alert_orcl11g.log > alert.log
Intercept the log between two strings
N matches the next line of the line
N appended to the next line
P print
P print to\ n
B unconditional jump does not match and then does not execute
T conditional jump does not match after execution
: fun1
When matching B, b func1 is similar to goto to jump to the previous A match
The splicing mismatch after N judgment
N filter mismatch after judgment
# sed'/ A / {ptincter fun1 1; n;: fun2 / B / {ptinceb fun1}; n; b fun2} 'file1-n
Find a specific string
Sed-n "/ 2010 print 13 print 30 php/ Jr. 2010 awk 17 awk 30 awk /" p awk | 2010-F:'/'. 'php/ {print $2}' | uniq-c
168576 13
301975 14
285616 15
299248 16
154377 17
Sed-n "/ 2010 action/ action/ / 2010 awk'{if ($3)} else if ($4) {print $4}}'| sort | uniq-c | sort-nr
533271 action=plInfo
132742 action=FriendPet
101258 action=Info
Awk'/ string 1 / {aqum1} a {b=b?b "\ n" $0VAND 0position if (baking / string 2 /) {print bounding b = ""}} 'file
Sed-n'/ string 1 / {ptince1} / {ptince1} / {ptince1tre / {ptsmb1} / {ptince2tre / {ptinceb1}; ntb2} 'file.
Awk'/ string 1 / {aqum1} a {b=b?b "\ n" $0VAND 0position if (baking / string 2 /) {print bounding b = ""}} 'file
Sed-n'/ string 1 / {ptincehterb};: mtterxbank _ lzj / {xtern _ politics / string _ 2 _ _! {bm;}; ptterb}; x 'file
After reading the above, do you have any further understanding of the common usage of Sed? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.