[sed] Print all the lines in between two patterns 17 Monday Dec 2012 Posted by kousik in cli, sed ≈ 2 Comments Tagscli, match, matching, pattern, print, script, sed The following CLI one-liner prints all the lines between the lines containing PATTERN1 and PATTERN2 (including the lines with these two patterns) in a file, FILENAME: sed -n '/PATTERN1/,/PATTERN2/p' FILENAME Rate this:Share this: Share on Reddit (Opens in new window) Reddit Share on X (Opens in new window) X Share on Facebook (Opens in new window) Facebook Email a link to a friend (Opens in new window) Email More Share on LinkedIn (Opens in new window) LinkedIn Like Loading...