I have written a shell script and want to print output of 5 defined variables in csv file, I am using a condition, If condition 1 success then output should print in first 5 columns, else output should in next 5 columns, like below:
if condition 1 success
$DAY,$ModName,$Version,$END_TIME,$START_TIME
(should print in column number 1..5 of csv)
if condition 2 success
$DAY,$ModName,$Version,$END_TIME,$START_TIME
(should print in column number 6..10 of csv)
But using my code output always appends to next row
Below is my code:
if [ "$Version" = linux ]
then
echo "$DAY","$ModName","$Version","$END_TIME","$START_TIME" | awk -F "\"*,\"*" '{print $a ","}' >> output.csv;
else
echo "$DAY","$ModName","$Version","$END_TIME","$START_TIME" | awk -F "\"*,\"*" '{print $b}' >> output.csv;
fi
I tried n number of things apart from this code, but not able to find the solution.
I would appreciate your help :)
aandb, but you never assign a value to them.