Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

UNIX HELP You are part of a team working on a large C++ program. The source code

ID: 3726344 • Letter: U

Question

UNIX HELP

You are part of a team working on a large C++ program. The source code for this program is kept in the directory ~cs252/Assignments/commandsAsst/project. After a certain amount of debate, the team has decided to change the order of the parameters of the function binarySearch. Someone else is actually changing the definition of that function. Your job is to find all the places where that function is called and to make repairs as necessary. What command would you give to list all calls to that function? You should show the lines of code containing each call and the name of the file from in which each such line occurs. (It’s OK to produce a few incidental uses of the function name as well, because you will be inspecting the output before actually making the changes.)

Same problem, but suppose that all you wanted was a list of the source code file names in which the function was mentioned?

NOTE: I don't have access to ~cs252/Assignments/commandsAsst/project.

Explanation / Answer

Here is the Unix command as per your requirements.

grep -r -n -H sequentialInsert(.*)  ~cs252/Assignments/commandsAsst/project

Explanation:

·       r if you are specifying a directory this option will search for the pattern recursively all the files in the directory.

·       n displays line numbers that match the pattern.

·       H displays the file name containing the pattern.

If find all the files that function was mentioned in:

Find /directory path location -type f -iname ‘*.file extension name’

By the grep command to list out the file:

Find / directory path location -type f -iname ‘*.file extension name’ | xargs grep PATTERN

and last

ls *.file extension name