AWK

Some awk Oneliners

Replace all occurrences of string MY_PATTERN in input_file.txt with output of command /path/to/command.sh

awk '/MY_PATTERN/ {system("/path/to/command.sh")} !/MY_PATTERN/ {print $0} ' input_file.txt

Same as above, but command.sh expects a parameter which is in turn stored in environment variable $FOOBAR

awk '/MY_PATTERN/ {system("/path/to/command.sh "'$FOOBAR')} !/MY_PATTERN/ {print $0} ' input_file.txt