Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux regularity

2025-01-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Sed

The format of the sed command is that n within sed-n'nroomp filename single quotation marks is a number or character indicating the number of lines. The-n option shows how many lines we want to print, but irrelevant lines are not displayed.

First create a sed directory to copy the files of passwd to the sed directory and rename it to test.txt

Print out the first line of the test file # sed-n '1roomp test.txt* to remove the-n parameter is to print out all the lines or regular expression printing # sed-n' 1 test.txt* specified interval printing 1 to 3 lines # sed-n'1 test.txt* printing a character # sed-n'/ root/'p test.txt* this usage is similar to grep Special characters used in grep, such as ^ $. * etc.) can also be used in sed using the * print first behavior root (^ represents the first line, printed with root at the beginning) # sed-n'/ ^ root/'p test.txt* prints the last line bash ($represents the last line) # sed-n'/ bash$/'p test.txt* prints a line greater than three o # sed-n'/ ooo*/'p test.txt

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report