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 > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article focuses on "Linux regular expressions and file formatting processing", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Now let the editor to take you to learn "Linux regular expressions and file formatting processing"!
Regular expression and document formatting basic regular expression character aggregation (characters)
Sed tool
Sed itself is also a pipeline command, you can analyze standard input! And sed can also replace, delete, add, retrieve specific rows, and so on.
Example 1: list the contents of / etc/passwd and print the line number. At the same time, please delete line 2-5!
[dmtsai@study ~] $nl / etc/passwd | sed'2 format and related processing of root:x:0:0:root:/root:/bin/bash6 sync:x:5:0:sync:/sbin:/bin/sync7 shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown file
Formatted printing: printf
Example 1: list only the name and score of the file (printf.txt) of the data just above: (separated by [tab]) [dmtsai@study ~] $printf's\ t% s\ t\ n'$(cat printf.txt) Name Chinese English Math AverageDmTsai 80 60 92 77.33VBird 75 55 80 70.00Ken 60 90 70 73.33awk: useful data processing tool
Awk is also a great data processing tool! Rather than sed, which often acts on an entire row, awk tends to split a row into several "fields". Therefore, awk is quite suitable for dealing with small data processing. The mode in which awk usually runs is as follows:
[dmtsai@study ~] $awk 'condition type 1 {Action 1} condition type 2 {Action 2}.' Filename
If I want to withdraw the account and the login's IP, and the account is separated from the IP by [tab], it will look like this:
[dmtsai@study ~] $last-n 5 | awk'{print $1 "\ t" $3} 'dmtsai 192.168.1.100dmtsai 192.168.1.100dmtsai 192.168.1.100dmtsai 192.168.1.100dmtsai Fri file comparison tool diff example 1: compare the difference between passwd.old and passwd.new: [dmtsai@study testpw] $diff passwd.old passwd.new4d3
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.