send mail using mail command in UNIX

Rating 2.00 out of 5

Sometimes we need to send e-mails from UNIX command-line itself. Sometimes we need to write a small script to do so. Here’s what we need to do for such tasks.

We can send mail in UNIX using “mail” command. Syntax is as follows,

mail -s “Subject” -c “any_cc_email_id” -b “any_bc_email_id” “comma_separated_To_email_id”

But the above syntax . . . → Read More: send mail using mail command in UNIX

Find all files having some pattern using grep in UNIX

Rating 3.67 out of 5

How to find all files under a directory, having a pattern, in their name or content,  in UNIX?

grep command can be used in conjunction with xargs to fetch filenames having some pattern in them.

find  /search_dir/ -iname  “*.*” -print0 | xargs -0 grep ”PATTERN”

where,
search_dir is the directory where search has to begin from
PATTERN is the . . . → Read More: Find all files having some pattern using grep in UNIX