In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the relevant knowledge of "what are the common options for sed commands in linux". The editor shows you the operation process through actual cases, the operation method is simple and fast, and it is practical. I hope this article "what are the common options for sed commands in linux" can help you solve the problem.
Introduction to Sed
Sed is a new, non-interactive editor. It performs the same editing tasks as the editors vi and ex. The sed editor does not provide interactive use, and users can only enter editing commands on the command line, specify a file name, and then view the output on the screen. The sed editor is non-destructive and does not modify the file unless you use shell redirection to save the output. By default, all output lines are printed to the screen.
Sed working process
The sed editor processes the file (or input) line by line and sends the output to the screen. Sed's commands are those seen in the vi and ed/ex editors. Sed stores the row guarantees that are currently being processed in a temporary cache, which is called a pattern space or temporary buffer. After sed has finished processing the line in mode space (that is, after executing the sed command on that line), it sends the line change to the screen (unless there is a previous command to delete the line or cancel the print operation). Every time sed finishes processing the last line of the input file, sed ends running. Sed stores each line in a temporary cache and edits this copy so that it does not modify or destroy the source file.
Common options for sed
Common options for sed
Option description-n uses quiet mode. In general, all STDIN will be output to the screen, and only print when-n is added.
The line-e is specially processed by sed for multiple edits, and the command order affects the result-f specifies a sed script file to be executed on the command line, and-rSed uses extended regular-I to directly modify the contents read by the document without outputting the regular expression of Sed on the screen.
Regular expression metacharacters of sed
The match object of the metacharacter function example ^ first line locator / ^ love/ matches all lines starting with love $line end locator / love$/ matches all lines ending with love. Match the order except the line break
The character / l..e/ match contains the character l, followed by two arbitrary characters
Character, followed by the line * of the letter e, before matching zero or more
The leading character / * love/ match is followed by zero or more spaces
The line [] of the pattern love matches within the specified character group
Any character / [Ll] ove/ match line containing love and Love [^] match is not in the specified character
Any character in the group / [^ A-KM-Z] ove/ match contains ove, but the one before ove
Characters are not between An and K or M to Z
The line\ (..\) saves the matched characters
& save the lookup string in the
Replace the string with a reference to the s/love/**&**/ symbol & represents the lookup string. String love
Two quotes are added before and after the replacement.
With, that is, love becomes a * * love**\ / match that contains a word ending in love
Line x\ {m\} m consecutive x\ {5\} / there are 5 consecutive letters o,
At least 5 consecutive o, or 5 to 10
The row x\ {m,\} of consecutive o at least m x\ {5,\} /
At least m x, but not m x
More than n xplains\ {5pm 10\} /
This is the end of the introduction to "what are the common options for sed commands in linux". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
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.