Link to home
Start Free TrialLog in
Avatar of Nazrul10
Nazrul10

asked on

Grep >> Column Heading

Hello,
I am using following code to split data into a .txt file based on userid(another text file). I need to insert column heading into each .csv file that I am creating in each loop. How can I insert column heading in this case

while read userid
do
NEWFILE=${SIFFILEDIR}/${userid}.csv
#echo Processing $userid
grep $userid $BCPFILE  >> "$NEWFILE"
done < "$BCPUSERID"

Your help will be appreciate

Nazrul

fc-hist-Master-Account.sh
Avatar of cmurugavel
cmurugavel
Flag of United States of America image

Hi,

Your questions is unclear to me. Is it sybase question ?
I think you need to ask this in the Unix section.
Avatar of Nazrul10
Nazrul10

ASKER

Hello
it is a sybase question. I am transfering my sybase table data to fc_hist_Master_Account.txt. There are lots of column in this .txt file. userid is one of the column in this text file.
BCPFILE=fc_hist_Master_Account.txt
I have another .txt file named userid.txt that has only userid in a single column. I am reading userid from this .txt file and searching this userid into  fc_hist_Master_Account.txt and inserting into seveeral .csv file based on userid I am passing from userid.txt file.
I attached the file.
NEWFILE=userid.txt
I am trying to insert column heading in each .csv file when I am inserting data from  fc_hist_Master_Account.txt. So that when people open the .csv file they can understand what type of data in each column
Thanks
Nazrul



ASKER CERTIFIED SOLUTION
Avatar of alpmoon
alpmoon
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Answer should be
 echo "AccountCode,IECode,UserID,TotalFeeAmount,TotalTaxAmount,IEPayoutAmount" >> $NEWFILE