sed

Edit text in a scriptable manner. See also: awk, ed. More information: https://keith.github.io/xcode-man-pages/sed.1.html.

command | sed 's/apple/mango/g'

command | sed -f path/to/script_file.sed

command | sed -E 's/(apple)/\U\1/g'

command | sed -n '1p'

sed -i bak 's/apple/mango/g' path/to/file