get paragraph with awk, and start-of-line regexp get paragraph with awk, and start-of-line regexp unix unix

get paragraph with awk, and start-of-line regexp


^ means start-of-string. You want start-of-line which is (^|\n), e.g.:

$ awk -v RS='' -v ORS='\n\n' '/(^|\n)bbb/' fileaaa cccbbb aaa cccbbb aaa ccc