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
The latest download and installation tutorial of ...
Preface Whether it is a stand-alone lock or a dis...
Table of contents Preface Idea startup speed Tomc...
Query the MySQL source first docker search mysql ...
Table of contents introduction Install Homebrew I...
1. Use frameset, frame and iframe to realize mult...
count(*) accomplish 1. MyISAM: Stores the total n...
1. CSS writing format 1. Inline styles You can wr...
Why is NULL so often used? (1) Java's null Nu...
Temporary tables and memory tables A memory table...
Because if there is no forward slash at the end of...
Multi-way search tree Height of a complete binary...
Preface We all know that MySQL uses server-id to ...
Table of contents Cache function in vue2 Transfor...
This article shares the specific code for impleme...