In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
In the operation of linux, we often replace and count the strings in the file. Now let's do a collation. If there are any mistakes, please correct them.
Count the number of strings
Grep-c str filenamegrep-o str filename | wc-l
Replacement string
Replace the current line matching string
: s/oldStr/newStr
Replace all matching strings in the current file
:% s / original string / replacement string / gg
Batch replacement string
Sed-I "s / lookup field / replacement field / g" grep lookup field-rl path
-rl represents all subdirectories
Sed-I "s/new Str/old Str/g" 'grep "old Str"-rl filename'
PS:Linux common operation commands for strings
Split a string with a space
Awk'{print $1}'
Split a string with specific characters
Str=$ {str//,/}-/ / is followed by a glyph that splits the string, and the last / is followed by a space
Cut string
Cut-b |-c |-f 3-b represents bytes,-c represents characters, and-f represents the number of characters in the array following the field.
Remove specific characters from a string
Sed's /\ "/ / g's stands for substitution, the default character is replaced with blank, the character after\ is the character to be replaced, and g means replace all.
Summary
The above is the relevant operation skills of finishing strings in Linux introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave a message for me, and the editor will reply you in time. Thank you very much for your support to the website!
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.