Share it

1483515352 sir2 product retina




Mar 13, 2016
tashwan 7b17bfd26b

I want to remove some lines from this string.
Thanks for your attention.


Doing this with sed is very straight forward, you could just do s/^.*Line.*$// on the whole file.
sed -e’s/^.*Line.*$//’ file.txt > file-without-lines.txt

To keep the search-regexp in between / characters is done with ^.*Line.*$/

^ starting an anchor at the beginning of the string;
.* all the characters between the /
Line as many times as possible;
$ the end of the string.

Here’s a more flexible way you could do it with awk and some other tools:
awk ‘/^.*Line.*$/ {print > “file-without-lines.txt”}’ file.txt
awk ‘NR>1 && /^.*Line.*$/ {print > “file-without-lines.txt”}’ file.txt

The awk-approach will remove all lines from the first line in your file.
The bash approach will remove all lines from the second and all other lines.


You should read this answer to see if there are any other options than sed.
With grep -o:
awk -v RS= -v IGNORECASE= -v OFS= -v ORS=”
” -v FS=”$ORS” -F”$ORS” ‘$2~/^.*Line.*$/{++i; next} {print >”file-without-lines.txt”}’ file.txt

Note the -v globs, so that you can set IGNORECASE and OFS to false, which allows you to search for patterns with line breaks. Note also that RS must be set, otherwise each line will be a record of its own (1, 2, 3, 1,…).

Elderly and Unvaccinated Influenza Case Reports

Update: Based on an early report from the CDC, it appears that the three elderly and unvaccinated individuals that presented at the emergency departments in Northeast Ohio have all recovered.

The news isn’t as good for the young children and teens that