In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to use the sed-I command. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
[root@www ~] # sed [- nefr] [Action] options and parameters:-n: use silent mode. In the general use of sed, all data from STDIN is generally listed on the terminal. But if you add the-n argument, only the row (or action) that has been specially handled by sed will be listed. -e: edit the action of sed directly on the command line mode;-f: write the action of sed directly in a file, and-f filename can run the sed action in filename;-r: the action of sed supports the syntax of extended normal representation. (the default is the basic regular representation syntax)-I: directly modify the contents of the read file instead of outputting it to the terminal. Action description: [N1 [, N2]] functionn1, N2: may not exist, generally stands for "the number of lines selected for action". For example, if my action needs to be carried out between 10 and 20 lines, then "10 minutes 20 [Action behavior]" function:a: added, strings can be connected after a, and these strings will appear on a new line (the current next line) ~ c: instead, c can be followed by a string These strings can replace the lines between N1 and N2! D: delete, because it is deleted, so there is usually no knock after d; I: insert, I can be followed by strings, and these strings will appear on a new line (the current previous line); p: print, also about to print some selected data. Usually p will run with the parameter sed-n ~ s: replace, you can directly replace the work! Usually the action of this s can be matched with the formal representation! For example, 1Magazine 20s Universe, OldCompact newscop g is it!
Sed-I operates directly on text files.
Sed-I's / original string / new string /'/ home/1.txtsed-I's / original string / new string / g' / home/1.txt
The difference between these two commands is, look at the example.
This is the content of 1.txt.
# cat 1.txtdddd#ff
Let's look at the difference between the execution of these two orders.
Sed-I's Universe 7523 sed / home/1.txt execution results 75237523dd#ffsed-I's Universe 7523 Universe g' / home/1.txt execution results 7523752375237523#ff
Remove the first letter @ with "@" at the beginning of the line
Sed-I's / ^ @ / / 'file
Insert a new line before the line of a specific string
Sed-I'/ specific string / I new line string 'file
Insert a new line after the line of a specific string
Sed-I'/ specific string / a new line string 'file
Deletion of a specific string
Sed-I'/ string / d 'file Thank you for reading! This is the end of the article on "how to use the sed-I command". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
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.