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: logc and
logpy 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
Write a grep command that will look for singleline comments in the both files
logpy and logc
Note:
a Python singleline comments can start with # while C singleline comments
start with
b c Lines that start with #include or #define should not be matched.
The matched singlecomments should start with line; lines has code and end
with a singlesingle line comment should not be matched.
d To simplify the BRE, you can use Linux pipelining to run two grep commands
backtoback 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
