In Linux operations, we often replace and count strings in files. Let's do a summary now. If there are any mistakes, please criticize and correct them. Count the number of strings grep -c str filename grep -o str filename |wc -l Replace String Replace the current line with the matching string Replace all matches in the current file :%s/original string/replacement string/gg Batch replace string sed -i "s/search field/replace field/g" grep search field-rl path -rl means all subdirectories sed -i "s/new Str/old Str/g" 'grep "old Str" -rl filename' PS: Linux commonly used string operation commands Split string by space Split a string at specific characters Cutting a string Remove specific characters from a string Summarize The above is the relevant operation skills for organizing strings in Linux introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: MySQL uses init-connect to increase the implementation of access audit function
>>: Vue project configures webpack-obfuscator to implement code encryption and obfuscation
During the development process, I often encounter...
This article example shares the specific code for...
/****************** * Linux kernel time managemen...
When using Flex layout, you will find that when a...
Table of contents background What are the methods...
HTTP Status Codes The status code is composed of ...
Preface MRR is the abbreviation of Multi-Range Re...
What is a tree in web design? Simply put, clicking...
Specify in CSS style file #class td /*Set the tab...
cause When executing the docker script, an error ...
I saw a good idea and recorded it. I have used jQ...
Table of contents 1. About JavaScript 2. JavaScri...
I remember when I was interviewing for my current...
This article example shares the specific code of ...
This article example shares the specific code of ...