#extracts the ip address from ifconfig /sbin/ifconfig sed -e 's/[^i]*inet addr:\([0-9.]*\).*/\1/p' -e d #extracts email addresses tr '\t' '\n' < custemail.txt | grep '.*@.*' # also extracts email addresses awk '/@/ { s = $0; while (match(s, /[^ ]+@[^ ]+/) > 0) { print substr(s, RSTART, RLENGTH); s = substr(s, RSTART + RLENGTH) } }' # dont forget sort and uniq to remove duplicate lines in a file