In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
6.2 The three great Linux tools.
grep,sed(stream editor), awk
sed basic usage
sed :Stream EDitor
Line Editor (Full Screen Editor: vi)
sed: pattern space
By default, the original file is not edited, only the data in the pattern space is processed: then, processing
When finished, print pattern space to screen
sed [options] 'AddressCommand' file ...
-n: Silent mode, no longer the default display mode space content
Address:
1 StartLine,EndLine
For example 1, 100 (lines 1 to 100)
$: Last line
2 /REGEXP/
For example/^root/
sed '/oot/d' /etc/fstab
3 /Pattern1/,/Pattern2/
Indicates the beginning of the row first matched by Pattern1, to the first matched by Pattern2
Match to the end of the row, all the rows in between
4 LineNumber
the specified row
sed '1d' /etc/fstab
5 StartLine,+N
Starting from StartLine, N lines backward, N+1 lines in total
sed '1,+2d' /etc/fstab
Command:
d: Delete eligible rows
p: Display eligible rows
a \string: appends a new line after the specified line with the content "string"
\n: Can be used for newlines
i \string: appends a new line with the content "string" before the specified line
r FILE: Adds the contents of the specified file to the qualifying line
w FILE: Save lines in the specified range of addresses as specified files
s/pattern/string/modifier: find and replace (default only replaces the first time in each line
String matched by pattern)
modifier
g: Global substitution
i: ignore case
sed '1,2d' /etc/fstab
sed '/^\//d' /etc/fstab
sed '/^\//a \# hello world' /etc/fstab
sed '/^\//a \# hello world\n # hello,linux' /etc/fstab
sed '2r /etc/issue' /etc/fstab
sed '/oot/w /tmp/oot.txt' /etc/fstab
sed 's/oot/OOT/' /etc/fstab
sed 's/^\//#/' /etc/fstab
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.