1
Below is the code to print contents of files present in the directory File contents are :
apple
banana
grapes
mango
names=()
FILES=/path_to_dir/*
for f in $FILES
do
names+=($f)
done
result="$(cat ${names[@]})"
echo "$result"
echo "The names are "$result"" | mailx -s "names are " abc@gmail.com
for this I am getting below output for result variable
apple
banana
grapes
mango
However when I print "$result" in email I got below output in email's text:
apple banana grapes mango
I want to send names in email with multiline like this :
apple
banana
grapes
mango
How to achieve the same?