Renumbering of COBOL Source code

Hi,

I have written awk script to replicate RENUM function of ISPF.

Please anyone has simple script than that.

awk '{i=i+10;line=substr($0,7,73); printf("%06d%s\n", i, line) }' ABC.cob

where ABC.cob is Cobol source code.

Looks OK to me. I dont't think, it can be done much easier, just in a different way :slight_smile:

I haven't written any COBOL in more than 30 years and even then I wasn't a big fan of GOTO. But, it used to be fairly common practice to have the source line number be part of the paragraph label used as the target of a GOTO statement. If that is being done in the source you're renumbering, you may need to consider altering more than just the line number fields while you're updating the code.

awk '{printf("%05d0%s\n", NR, substr($0,7,73)) }' ABC.cob

Actually, none of the suggestions handle the case wherein any line of COBOL source code starts with tabs. In these cases, each of these solutions might eat up parts of actual source code.