Kategori : Linux Ubuntu16 Mei 2019 12:31:06

Ubuntu Search and Show Multiple Line On Text Base On Search Keyword

1. Using Grep

Using grep you can do search with this format, grep -A number_of_line search_keyword file, example :

grep -A 3 2016-07-13 file

Command above will get 3 line from file, start from search keyword

2. Using Sed

With sed you can search with this command, sed -n '/start_search_keyword/,/end_search_keyword/p' file, example :

sed -n '/2016-07-13/,/2016-07-19/p' file

Command above will search inside file and show line that include 2016-07-13 to 2016-07-19

 

Source : https://askubuntu.com/questions/800769/how-to-get-text-from-range-of-dates-using-grep-sed-in-large-text-file

Share : Share Facebook Share Twitter
Kategori : Linux Ubuntu16 Mei 2019 12:31:06

©2011