I have a csv file that looks like this:
2017-06-01,3967485,Completed,local,in,0,13492,11746,2017-06-27 14:13:47+00,2017-06-27 14:20:16+00,389,ddb19040,mydomain.net,yourdomain.net,""
2017-07-01,3967488,Completed,local,in,0,13492,11746,2017-07-27 14:13:47+00,2017-06-27 14:20:16+00,389,ddb19040,mydomain.net,yourdomain.net,""
What I need to do is write a bash script that will loop through this file line by line, and grab the first field as one value, and then save the rest of the line without the first field (and comma) as a separate variable.
I have the following code so far:
for aline in $(cat /tmp/test.csv); do
echo $aline
done
But i'm not sure how to parse each line. Any pointers would be appreciated.
EDIT1
Using the suggested answer produces the following output in new_file
,Completed,local,in,0,13492,11746,2017-06-27 14:13:47+00,2017-06-27 14:20:16+00,389,ddb19040,mydomain.net,yourdomain.net,""
,Completed,local,in,0,13492,11746,2017-07-27 14:13:47+00,2017-06-27 14:20:16+00,389,ddb19040,mydomain.net,yourdomain.net,""
I'd like it to include field2 ($b in the suggested answer) at the start of each line
grab… as one value, and… as a separate variable
. – Sparhawk Feb 28 '18 at 23:25,Completed...
is the third column to the rest! – αғsнιη Mar 01 '18 at 04:50