In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to use the linux command line tool for text line filtering, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Common command line tools
Next, we mainly use head,tail,sed and awk, these tools. Among them, sed and awk tools are very powerful, using them to filter text may be a bit overqualified, but basically all tasks can be done through head and tail commands, and head and tail are more convenient for daily use.
Usage example
Preparatory work
Type the following command to generate a test file.
$seq-f "Line No g" 10 > lines.txt
Show only the first three lines of the text
This can be done through the head command, with the following command and output:
$head-n 3 lines.txt
Line No 1
Line No 2
Line No 3
Or through the sed command, the specific command and output are as follows:
$sed-n '1jue 3p' lines.txt
Line No 1
Line No 2
Line No 3
The awk command can also be completed.
$awk 'NR=5' lines.txt
Line No 5
-- slightly--
Line No 10
Display only the penultimate lines 3 to 1 of the text
To do this with head:
$head-n-2 lines.txt
Line No 1
Line No 2
Line No 3
Line No 4
Line No 5
Line No 6
Line No 7
Line No 8
Show only lines 6 to 8 of the text
Use head and tail tools:
$
< lines.txt head -n 8 | tail -n 3 Line No 6 Line No 7 Line No 8 sed的方法: $ sed -n '6,8p' lines.txt Line No 6 Line No 7 Line No 8 awk的方法: $ awk '(NR>= 6) & & (NR
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: 291
*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.