I have a input.txt file with following format:
Name age number address
mark 23 89756342192 chennai
david 40 70214789023 delhi
How do I create a CSV file from a TXT file as per the following example? Thanks.
mark,23,89756342192,chennai
david,40,70214789023,delhi
Below is the script i have written
printrep.sh
#!/bin/sh
Headers=["Name","Age","Phone","Address"];
count=$(wc -l < $name)
i=0;
echo "Headers[0] + ' , ' +Headers[1]+ ' , ' +Headers[2] + ' , ' +Headers[3] + ' , ' +Headers[4]";
while [ $i -lt $count ]
do
read line | awk FS=' ' OFS="," '{print $0}'
i=`expr $i + 1`
done
The above code is unable to display the output. And i Can't figure what is wrong. Please help I am a beginner to shell scripting
printrep.sh
would benefit from being passed through shellcheck.net It's clear that either you've not tried to run it or else you're not telling us the errors you have received.