Question

INTRO TO UNIX COURSE Comments in C++ come in two forms: the block format started by...

INTRO TO UNIX COURSE

  1. Comments in C++ come in two forms: the block format started by a /* and ending with a */, often on different lines, and the inline format started by // and ended at the end of the line.

    What command would you give to list all lines of commented.cpp that contain inline comments?

  2. What command would you give to print (display on the screen) the contents of commented.cpp with all inline comments removed (and no other changes to the text)?

I need help with these grep commands.  

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1. grep "//" commented.cpp

This grep command lists all lines of commented.cpp that contain inline comments.

2. grep -v "^(//)" commented.cpp

This command lists all lines that are not commented.

Add a comment
Know the answer?
Add Answer to:
INTRO TO UNIX COURSE Comments in C++ come in two forms: the block format started by...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • What command would you give to print (display on the screen) the contents of commented.cpp with...

    What command would you give to print (display on the screen) the contents of commented.cpp with all inline comments removed (and no other changes to the text)? I need to do this with the sed command, and as you know all inline comments in cpp start with "//".

  • QUESTION 1 What will be the output of following Unix command: find / -name ‘*’ A....

    QUESTION 1 What will be the output of following Unix command: find / -name ‘*’ A. List all files and directories recursively starting from / B. List a file names * in / C. List all files in / directory D. List all files and directories in / directory QUESTION 2 Which command is used to extract a column/field from a text file / input. A. paste B. get C. cut D. tar QUESTION 3 Which command creates an empty...

  • INTRO TO UNIX COURSE Suppose that you wished to copy all of the text files from...

    INTRO TO UNIX COURSE Suppose that you wished to copy all of the text files from your fileAsst directory and all of the files from your fileAsst/Planes directory into your current directory (without typing out the name of each individual file). What command would you give to make that copy? Direct Paths I wish to copy from:   /home/ndashiel/UnixCourse/fileAsst /home/ndashiel/UnixCourse/fileAsst/Planes Direct Path I would like to copy into: /home/ndashiel/UnixCourse/commandsAsst Please help me with this, I have been struggling on this for...

  • UNIX?LINUX course. You are working on a documentation file userNotes.txt with some members of your software...

    UNIX?LINUX course. You are working on a documentation file userNotes.txt with some members of your software development team. Just before the file needs to be submitted, you manager tells you that a company standard requires that one blank space be left between the end-of-sentence period (.) and the start of the next sentence. (This rule does not affect sentences at the very end of a line.) For example, this is OK: Turn the knob. Push the “on” button. This is...

  • LINUX QUESTIONS (dont have to display output, I will be running these commands myself to check...

    LINUX QUESTIONS (dont have to display output, I will be running these commands myself to check the output) Display the command(s) used to do the following: create an empty file called history by using just a redirection operator. Verify and show. Show/verify all results (i.e., all commands and their corresponding outputs). Wait 1 minute or more and then display the command(s) used to do the following: change the timestamp on the history file you just created. Verify/display the change. Show/verify...

  • Project 1: Implementing a Shell 1 Overview In this individual project you will have to design...

    Project 1: Implementing a Shell 1 Overview In this individual project you will have to design and implement a simple shell command interpreter called mysh. The basic function of a shell is to accept lines of text as input and execute programs in response. The shell must be able to execute built-in commands in a process different from the one executing mysh. 2 Requirements When first started, your shell should initialize any necessary data structures and then enter a loop...

  • Hello all, I have a c++/unix (bash) question. I am struggling on starting this assignment. If...

    Hello all, I have a c++/unix (bash) question. I am struggling on starting this assignment. If you could start the assignment and tell me how to do the rest it would be greatly appreciated! (Quick thumbs up answer response if thorough and correct) Maintain automobile records in a database Write a shell script to create, view and modify a simple database that contains automobile records. The shell script has to be done in Bourne shell syntax (bash as a matter...

  • Writing Unix Utilities in C (not C++ or C#) my-cat The program my-cat is a simple...

    Writing Unix Utilities in C (not C++ or C#) my-cat The program my-cat is a simple program. Generally, it reads a file as specified by the user and prints its contents. A typical usage is as follows, in which the user wants to see the contents of my-cat.c, and thus types: prompt> ./my-cat my-cat.c #include <stdio.h> ... As shown, my-cat reads the file my-cat.c and prints out its contents. The "./" before the my-cat above is a UNIX thing; it...

  • do numbers 4-8 4. Given any directory, use the Is command to display: • all files...

    do numbers 4-8 4. Given any directory, use the Is command to display: • all files and sub-directories starting with the letter "D" (note do not list anything in any sub-directory) • its immediate sub-directories (sub-directories only, and no other ordinary files) its immediate hidden sub-directories only - take a screenshot (#3-3) that clearly shows the command and the result. 5. Assume that the following files are in the working directory: $ ls intro notesb ref2 section 1 section3 section4b...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT