I am learning bash scripting and trying to use awk to find a word or two from one file, and then replace a placeholder in a template text file with the word saved in awk. Looks like this:
echo "What's the class name?"
read $CLASS
and then use the class as a pattern to find a particular line and column:
NAME=$(awk '/$CLASS/ {print $2}' info.txt
and replace the word in a template with SED:
sed -i 'a/Name/$NAME/g' $FILE
I need to do this for several different columns and different parts of the template, so I can't save the whole awk command in a variabl. right now as it is, it is taking the whole column instead of just the line beginning with the pattern. (So i get a bunch of names instead of just one)
I have tried it a million ways and can't seem to get it to work properly. Any insight? This is my first post to Stack Overflow! :)
EDIT: the file I'm getting information FROM would look something like this:
stac1000 Joe 700
dbas1400 Sally 701
prog 1200 Rick 702
the template file that I'm replacing values of is a cover page template. I copy it to a new file and then replace the following values with ones from the info file. The aim is to be able to make several files that look the same but with different information from different lines in the info text:
Class
Name
Section