I have a bash script that takes three arguments, and I have a text file with three columns. I'd like the script to take the the text file's first, second, and third columns as the first, second, and third arguments of the bash script.
I'm a beginner with shell scripting, and am running fairly simple programs where efficiency is not very important, so simpler fixes would be appreciated :)
Here's an example of what I'd like to do.
I have a text file called food.txt with the following text:
fruits apples bananas
vegetables kale broccoli
meats pork beef
desserts cake pie
And I have a menu.sh script like this
#!/bin/bash
arg_1=$1
arg_2=$2
arg_3=$3
for arg_1 in $(cat food.txt)
do
echo "${arg_1}:${arg_2},${arg_3}"
done
I would like menu.sh to output this:
fruits:apples,bananas
vegetables:kale,broccoli
meats:pork,beef
desserts:cake,pie
But instead it outputs this:
fruits:,
apples:,
bananas:,
vegetables:,
kale:,
...
Thanks in advance for the help!