I am writing a script wherein rather than writing over the existing data, I would like to write to the next empty line in the csv file.
Current Output
texta,2
textb,
filed1,field2,field3
1,abc,123
2,xyz,124
Expected Output
texta,2
textb,
filed1,field2,field3
1,abc,123
2,xyz,124
1,jkl,547
The current code which writes over the existing data in the file
#! /bin/bash
echo "Enter file name"
read name
if [ condition ]
then
#commands
else
echo "Enter alphabets"
read alpha
echo "Enter number"
read number
echo "1,$alpha,$number" >> ${name}.csv
fi
Example input here aplha = jkl
and number = 547
This will write over the entire data but I would like to write only to the next empty line each time the if
condition fails. Any help is appreciated.