I have a list.csv with the following content:
"date";"Mr. Green Tree"
"date";"Mr. Red Apple"
"date";"Mr. Blue Car"
I use awk + sed to get the following output:
awk -F ";" '{print $2 }' list.csv | sed 's/"//g'
Output:
Mr Green Tree
Mr Red Apple
Mr Blue Car
Now I want to use the same command in a for loop and add the string "Hello"
script.sh
get_name () {
name=$(awk -F ";" '{print $2 }' list.csv | sed 's/"//g')
for string in $name; do
echo "Hello" $string
done
}
get_name
Output when I execute script.sh:
Hello Mr
Hello Green
Hello Tree
Hello Mr
Hello Red
Hello Apple
Hello Mr
Hello Blue
Hello Car
Expected Output:
Hello Mr Green Tree
Hello Mr Red Apple
Hello Mr Blue Car