I am not being able to use sed to print the content of the file from the beginning until the matching pattern as to when it finds the first occurrence of the pattern it stops and does not print all the matching patterns.
As the file size is greater than 25GB. However, below is a small example of the problem.
Eg: The content of the file is:
2010T10:11:12 some data.
2012T10:11:12 some data.
2013T10:11:12 They all are different data
2014T10:11:12 Logs basically
2014T10:11:12 Error Logs
2014T10:11:12 Any Data
2014T10:11:12 Data
2015T10:11:12 Some fields
2016T10:11:12 etc
Basically, when I give the range from 2010T10:11:12 - 2014T10:11:12 it should print till the 7th line of the file.
The command I am using for printing is:
sed -n '1,/2014T10:11:12/p' File-1.txt
Output:
2010T10:11:12 some data.
2012T10:11:12 some data.
2013T10:11:12 They all are different data
2014T10:11:12 Logs basically
Expected Output:
2010T10:11:12 some data.
2012T10:11:12 some data.
2013T10:11:12 They all are different data
2014T10:11:12 Logs basically
2014T10:11:12 Error Logs
2014T10:11:12 Any Data
2014T10:11:12 Data
This command duplicates the first line of the match pattern:
sed -n '1,/2014T10:11:12/p;/2014T10:11:12/p' File-1.txt
Output:
2010T10:11:12 some data.
2012T10:11:12 some data.
2013T10:11:12 They all are different data
2014T10:11:12 Logs basically <- Duplicate line. Need to
2014T10:11:12 Logs basically <- remove any one of them
2014T10:11:12 Error Logs
2014T10:11:12 Any Data
2014T10:11:12 Data
Another issue is that the content of the file changes every second so we cannot give any range like 1-7 or 5-7. It has to be on the basis of the pattern like 2010T10:11:12 - 2014T10:11:12 or 2015T10:11:12 - 2016T10:11:12.