Huu Phan | Blog Linux operating system | Linux operating system -Blog Huu Phan | www.huuphan.com
huuphan.com. Powered by Blogger.

My blog about Open Source: Zimbra Mail Server,linux,bash script,centos,linux command...

sed command regex example

In this tutorial, To use sed command regex such as: Lines starting from A till B printed, how to print between A line to B line , so on.

sed command regex example

The content sed_test file as picture below:


Lines starting from 10 line till 15 line printed 
[[email protected] ~]$ sed -n '10,12p' sed_test
The output as below:
    10    operator:x:11:0:operator:/root:/sbin/nologin
    11    games:x:12:100:games:/usr/games:/sbin/nologin
    12    ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
How to Lines starting from 10 line till end line printed 
[[email protected] ~]$ sed -n '10,$p' sed_test 
The output as picture below:

Conclusion 

Thought the article, you can printed line to line of file use sed command. How to Lines starting from A line till end line printed 


post new :

Huu Phan | Blog Linux operating system | Huu Phan ~ Zimbra Mail Server,linux,bash script,centos,linux command | www.huuphan.com

This Blog is protected by DMCA.com