Delete / Remove a line with string / word on Linux

Delete / Remove a line with string / word on Linux

 

1. View the file on Linux

[root@Centos6 bashscripts]# cat test
test 1
test 2
test 3
test 4
test 5
test 6
test 7
test 8
test 9
test 10
[root@Centos6 bashscripts]#

2. We want to remove “test 6” line on this file

[root@Centos6 bashscripts]# sed -i ‘/6/d’ test

6. Re-view this file

[root@Centos6 bashscripts]# cat test
test 1
test 2
test 3
test 4
test 5
test 7
test 8
test 9
test 10
[root@Centos6 bashscripts]#

That’s all. Thanks for using IThelpblog.com.

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>