I am trying to get this file to show Author before the CSV which is the "," only the first name shows
The bash shell's set
command is not the one you want in this context - it is used for setting the value of shell options and positional parameters.
Specifically, the command set INPUT=0
sets the value of the shell's first positional parameter, $1
, to INPUT=0
. Then set IFS=,
replaces it with IFS=,
. The correct assignments would simply be INPUT=0
and IFS=,
respectively.
HOWEVER, the only place that the value of IFS
appears to be significant is in your read
command - and there you can set it locally i.e.
while IFS=, read -r author title isbn
so you don't need to set IFS=,
elsewhere. You should also get into the habit of quoting variable expansions. So
while IFS=, read -r author title isbn
do
echo "$author"
done < Proj2.sorted