Need to write a script to reformat a file in unix but not familiar with unix

unix script must do the fiollowing

open a file containing comma delimited records
> each record contains 10 fields
> removes the 2nd field and use that same field containing fields 2 to 10
the original record after fprocessing should containing fields 1 and 3
a new erecord must be created for each record if coloumn 2 has a value
if it doesnt have a value then just remove field from original record hence making

Posting the source files (at least a few lines as a sample) and the output you desire would go a long way here.

Is this a homework question?

Can you give an explanation of your real-world problem?

see files attached file before is before conversion file after is what is expected after n:B if field obene of field two is empty then record must not be created
field one or field two must exist
n not a homework question trying to format a file before it goes into a perl program
so far this is what i have got
but it doesnt fit the criteria for when field one ot two is empty
i #!/bin/ksh
#
#
cnt=1
IFS=','
while read fld1 fld2 rest
do
if [ cnt -gt 1 ]; then
echo $fld1, $rest
echo $fld2, $rest
fi
cnt=`expr $cnt+1`
done < CustomerData.txt | sed 's/ /,/g'

Assuming you have a header (1st line) in the file:

awk -F, 'NR==1 || NF < 10 {print;next}
{
 s1=$1; s2=$2
 $1=$2=""
 sub(",,",",")
 print s1 $0
 print s2 $0
}' OFS="," filebefore.txt > fileafter.txt 

Thanks franlyn
tried code but it still doesnt facilitate if field 1 or field two is empty
dont create record in that scenario .
Look at file attached
record 1 should only create one record starting with 90003371001

record 3 should only create 1 record with 12406071240597as firts feild

awk -F, 'NR==1 || NF < 10 {print;next}
{
 s1=$1; s2=$2
 $1=$2=""
 sub(",,",",")
 if(s1) print s1 $0
 if(s2) print s2 $0
}' OFS="," file > new_file

Thanks danmero
that works perfectly

I can take credit only for if condition :cool: everything else should go to Franklin52 :b:

well thank you all

iuis there a way for me to tun the bash script from a perl program?