Filtering out comments from COBOL programs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Filtering out comments from COBOL programs
# 1  
Old 05-10-2017
Filtering out comments from COBOL programs

In SCO Unix, I have a working script to give me a list of COBOL (files end in .cbl) programs containing a specific variable ($1) on a line which is not a comment. The output of the first grep will be the full path to a file, a colon, and the contents of the line where this variable is found.

The usual way to comment a line is to place an asterisk(*) in column 7 so a grep which excludes a colon, six characters which could be anything, and an asterisk works. I am trying to take out a type of comment starting with spaces or tabs followed by "*>" but thus far, no progress.
Code:
grep $1 /u/dir1/cobsrc/cpy/*.cbl | grep -v ":......\*" |\
   grep -v -E ":[  ]*\*>" >>/usr/tmp/a.x$tstamp

I am trying to insert the "grep -v -E" and the bracket contains a space and a tab. This new grep doesn't filter out anything.

The script ends when a sed reads the temporary file and takes out the colon and everything that follows it which is then passed to sort -u.

TIA
# 2  
Old 05-10-2017
Quote:
Originally Posted by wbport
In SCO Unix, I have a working script to give me a list of COBOL (files end in .cbl) programs containing a specific variable ($1) on a line which is not a comment. The output of the first grep will be the full path to a file, a colon, and the contents of the line where this variable is found.

The usual way to comment a line is to place an asterisk(*) in column 7 so a grep which excludes a colon, six characters which could be anything, and an asterisk works. I am trying to take out a type of comment starting with spaces or tabs followed by "*>" but thus far, no progress.
Code:
grep $1 /u/dir1/cobsrc/cpy/*.cbl | grep -v ":......\*" |\
   grep -v -E ":[  ]*\*>" >>/usr/tmp/a.x$tstamp

I am trying to insert the "grep -v -E" and the bracket contains a space and a tab. This new grep doesn't filter out anything.

The script ends when a sed reads the temporary file and takes out the colon and everything that follows it which is then passed to sort -u.

TIA
Let me bring attention to the highlighted parts.'
":[ ]*\*>" A colon `:' followed by either one or more space or space, followed by a literal `*' followed by a `>'. That's not what you described and I highlighted.

Maybe, grep -v -E '[[:space:]]*\*>'
# 3  
Old 05-11-2017
Hi.

Omitting sample input and output will probably decrease the likelihood of responders even looking at your problem.

Best wishes ... cheers, drl

Code:
To get the best advice on transforming, extracting, manipulating data,
please supply your computing environment and problem context:

1. OS and shell, preferably with versions
2. Representative sample input
3. Output desired that corresponds to the input
4. Logic to obtain output from input
5. Attempts at a solution that you have tried, including output

Post code and data inside CODE tags.

If you need to use or to avoid certain tools, you may need
to explain why, especially if your post count is low. Once the
problem is identified, responders often can choose the most
appropriate tool, not necessarily the one you might want.

These guidelines allow responders to create solutions without
ambiguity and to avoid creating sample data sets.

# 4  
Old 05-11-2017
I got it to fly by putting a space followed by a tab inside the "[]". Some dummy test files had various combinations of space(s) and tab(s) in front of "*>", and these did not show up.

Thanks for looking at it.
Resolved.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Difference between inbuilt suid programs and user defined root suid programs under bash shell?

Hey guys, Suppose i run passwd via bash shell. It is a suid program, which temporarily runs as root(owner) and modifies the user entries. However, when i write a C file and give 4755 permission and root ownership to the 'a.out' file , it doesn't run as root in bash shell. I verified this by... (2 Replies)
Discussion started by: syncmaster
2 Replies

2. What is on Your Mind?

How safe is Dropbox and Ubuntu one? Would you store critical files or programs there? Any comments o

How safe is Dropbox and Ubuntu one? Would you store critical files or programs there? Any comments on the guarantee that the two companies provide and on the technology used for encryption? (1 Reply)
Discussion started by: frad
1 Replies

3. Shell Programming and Scripting

Sed script, changing all C-comments to C++-comments

I must write a script to change all C++ like comments: // this is a comment to this one /* this is a comment */ How to do it by sed? With file: #include <cstdio> using namespace std; //one // two int main() { printf("Example"); // three }//four the result should be: (2 Replies)
Discussion started by: black_hawk
2 Replies

4. UNIX for Dummies Questions & Answers

Are programs like sys_open( ) ,sys_read( ) et al examples of system level programs ?

Are the programs written on schedulers ,thread library , process management, memory management, et al called systems programs ? How are they different from the programs that implement functions like open() , printf() , scanf() , read() .. they have a prefix sys_open, sys_close, sys_read etc , right... (1 Reply)
Discussion started by: vishwamitra
1 Replies

5. SCO

cobol installation

Dear All, while installing mfcobol in sco open unix 5 in piv m/cs, when run #sh ./install this error massage is comming load error file lmfnewdb error code 198 pc=0 call=-1 seg=0 198 load failor chmod warrning can not acess /opt/lib/mflmf/mflmfdb no such file or directory (error-2)... (0 Replies)
Discussion started by: sudhir69
0 Replies

6. Shell Programming and Scripting

Calling script from RM cobol and returning value to cobol

Is there a way you can return a value from a script that is called from a rm cobol program... 01 WS-COMD-LINE-PGM X(39) value sh ./getUserId.sh 12345" 01 WS-RETURN-SYS-CODE PIC 9(8). CALL "SYSTEM" USING WS-COMD-LINE-PGM GIVING WS-RETURN-SYS-CODE. ... (1 Reply)
Discussion started by: pavanmp
1 Replies

7. Programming

cobol crn programme run on express cobol as .gnt

can i run .crn programme in express cobol which support to .gnt programme .... Plz tell me solution (2 Replies)
Discussion started by: bibi
2 Replies

8. UNIX and Linux Applications

Rm-cobol 85

Does anyone use the following Cobol compiler: RM/COBOL-85 Compiler - Version 5.15.00 for SCO Unix 386. I am looking for a file that might be part of the distribution named "osmain.o" Thanks. (0 Replies)
Discussion started by: jgt
0 Replies

9. Solaris

COBOL issue

Hi, I am working on a Mainframe to UNIX replatforming project. we are facing problems with COBOL COMP-3 fields. We are using the Mainframe emulator software to download the data which has COMP-3 fields and using it as input to the same COBOL programs which were copied from Mainframe and did the... (1 Reply)
Discussion started by: Jayaprakash T
1 Replies

10. Gentoo

COBOL on linux?!

Hello guys, I'm searching for a good COBOL compiler which runs on linux. In fact I have found one but I'm really lost with its installation!! I don't know how to install it and how it works. In fact I'm not so good in linux and I always have problems with installation, but this time it's... (1 Reply)
Discussion started by: HSN
1 Replies
Login or Register to Ask a Question