Page 1 of 1

sort - to insert a comment in file

PostPosted: Tue Oct 11, 2011 2:08 pm
by sjrcreation
Can we insert a comment line in a file before a fixed content, Eg

my file
*********
**********
****
1******
********
1*****
*******

requirement :
*********
**********
****
**comment**
1******
********
**comment**
1*****
*******
**comment**

i need to inset a comment before a constant 1 in 1st col.

Re: sort - to insert a comment in file

PostPosted: Tue Oct 11, 2011 11:43 pm
by Frank Yaeger
Your "rules" don't match your example. Why do you have the last **comment** when there's no 1 in the last record?

At any rate, if you want to insert a comment before each '1' record, you can use a DFSORT job like the following:

//S1 EXEC PGM=SORT                                 
//SYSOUT DD SYSOUT=*                               
//SORTIN DD *                                     
*********                                         
**********                                         
****                                               
1******                                           
********                                           
1*****                                             
*******                                           
//SORTOUT DD SYSOUT=*                             
//SYSIN DD *                                       
  OPTION COPY                                     
  OUTFIL IFTHEN=(WHEN=(1,1,CH,EQ,C'1'),           
    BUILD=(C'**comment**',/,1,80))                 


SORTOUT would have:

*********       
**********       
****             
**comment**     
1******         
********         
**comment**     
1*****           
*******