Print lines ending with string within a range of lines
sed -n '/dmitritelinov/,${/nologin$/p;}' /etc/passwd
The range of lines being chosen are starting from the line containing the pattern
dmitritelinov till the end of the file($).
The commands present within the braces are applied only for this range of lines. Within this group, only the lines ending with
nologin are printed.
To print the same between the
root and
dmitritelinov strings:
sed -n '/root/,/dmitritelinov/{/nologin$/p;}' /etc/passwd