Text Processing9 / 18
Up next

grep -i, -v, -c

#!/usr/bin/env bash

fruits=$'Apple\nbanana\nAPRICOT\ncherry'
# -i: ignore case
printf '%s\n' "$fruits" | grep -i 'ap'
# -v: invert, keep lines WITHOUT the pattern
printf '%s\n' "$fruits" | grep -v 'a'
# -c: count matching lines instead of printing them
printf '%s\n' "$fruits" | grep -ic 'ap' 
What you're solving

case-insensitive, invert, and count