0

I have the following code

#!/bin/bash
v=""
for f in a123*
do
  #   echo "Processing $f file";
  #mail -a $f -s " Test" Ab@gmail.com < /dev/null
  v=$v" -a "$f
done
mail $v  -s " Test" Ab@gmail.com < /dev/null

I have a procedure which converts table data into flat files and saves it in a directory. I need to mail those flat files according to email id which is being provided as input via procedure Right now I am hard coding the email id but I need to map the email id according to user input. The mail should be sent to the email ID provided by user.

ceving
  • 21,900
  • 13
  • 104
  • 178
Techie
  • 13
  • 2

1 Answers1

0

Take a look at the Bash Guide for Beginners.

Use the read function

read recipient

And later on

mail "$recipient"

See here how to generate fancy prompts.

BTW: use arrays and not string concatenation for command line options.

v=()
v+=(-a)
v+=(file)

mail "${v[@]}" ...
Community
  • 1
  • 1
ceving
  • 21,900
  • 13
  • 104
  • 178