Bash beginner

Hello so I've stored some csv data to be read into variables like this

Name,Team,Shop,Shoe
etc,etc,etc,etc

Code:

sep=","
{
 while IFS=$sep read Name Team Shop Shoe

do

count=1
   dirname=$Name
   while [ -d "$dirname" ]
   do
       ((count++))
       dirname="${Name}$count"
   done

   mkdir -p $dirname/{Personal,Food,Pictures}

#(1)
echo "Hello my name is $Name i play for $Team i shop at $Shop and my shoe size is $Shoe"  < $dirname/Personal/starter.txt

done } <$file_name

When using the mkdir command to make the directories based on $dirname it works perfectly and i get all directories made based on each name, however when trying to Echo text into a file called starter.txt it gives me an error says the file or name doesn't exist. I'm trying to get it to generate ths file for every user. This is the full error

Paul/Personal/starter.txt: No such file or directory 

this lists this error 20 times because of 20 users and 20 differnty names however is finding directory but not making file?

please help.

You are not redirecting stdout to a text file with < but redirecting stdin to read from a (yet) non-existing file.

1 Like

I think i get what you are saying but

COMMAND_OUTPUT >
# Redirect stdout to a file.
# Creates the file if not present, otherwise overwrites it.

I thought this would actually create if not preseent, have i done something wrong in the previous bit?

Look at the two different redirection operators!

1 Like

sorted it thank you, was so simple lol