I hope this isn't homework.
Easiest way is to use arrays:
Code:
#!/bin/sh -
array0=(`cat /tmp/name`); array1=(`cat /tmp/age`); array2=(`cat /tmp/country`)
for i in `seq 0 $[${#array0[@]}-1]`; do
echo "${array0[$i]},${array1[$i]},${array2[$i]}"
done
exit 0
Note that 0) this will only work if the position of the data in all files is synced, 1) if you have space separated values in any of the files you must fiddle with the IFS and 2) I assert you are capable of adding the double quotes back in yourself.
Code:
function help() { echo "Bash scripting guides:
http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
http://www.tldp.org/LDP/Bash-Beginners-Guide/html/index.html
http://www.tldp.org/LDP/abs/html/"; }
Nota bene: do yourself a favour and do not script as root account user.