Question: Use grep to search for specific lines in a c program utilizing Basic Regular Expressions ( BRE ) . The grep command should be executed

Use grep to search for specific lines in a c program utilizing Basic Regular Expressions (BRE).
The grep command should be executed as grep where is the required
regular expression and is a file name. Two files are given for testing: log3.c and
log3.py. Download the two files and apply the grep commands you will write to them. Some
tasks will involve the two files (search for patterns in both files simultaneously), in this case, the
grep command must be run as grep .
Tasks
1. Write a grep command that will look for single-line comments in the both files
(log3.py and log3.c).
Note:
a- Python single-line comments can start with # while C single-line comments
start with //
.
b- c- Lines that start with #include or #define should not be matched.
The matched single-comments should start with line; lines has code and end
with a single-single line comment should not be matched.
d- To simplify the BRE, you can use Linux pipelining to run two grep commands
back-to-back where the matched lines by the first grep command are passed as
input to the second grep command lines.
e- You can use the -v option in grep to exclude lines that match the BRE instead of
including them. For example, you can have the output from the first grep
command match all lines that start with # or // and then exclude those lines
that start with #include or #define in the second grep command.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!