Get the App
SLTechnology News&Howtos  ›  Servers  › 

Linux regularity

Shulou Source: shulou.com Published: 2022-06-02 15:04:43 10月03日 Update

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

Tags: Characters files directories regular special one line three representatives actions intervals parameters commands that is opening quotation marks copies numbers formats behaviors expressions Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Huawei Microsoft Docker NVidia