/bash/

.bash_aliases (grep email)

2020-05-01 13:00:00

xx_grep_email_from_file() {
    if [[ -f "$1" ]]; then
        grep -E -o "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}\b" "$1" | sort | uniq -i
    else
        echo "Expected a file at $1, but it doesn't exist." >&2
        exit 1
    fi
}
xx_grep_email_from_dir() {
    for file in $1*
    do
        if [[ -f $file ]]; then
        xx_email_from_file $file
        fi
    done
}