Questions

  1. Suppose you have a file with the following content:
Hello, sed is a powerful editing tool. I love working with sed
If you master sed, you will be a professional one

And suppose you use the following command:

$ sed 's/Sed/Linux sed/g' myfile 

How many lines will be substituted?

  1. Suppose you have the same file that was used in the previous question and you use the following command:
$ sed '2d' myfile  

How many lines will be deleted from the file?

  1. What is the location of the inserted line in the following example?
$ sed '3a\Example text' myfile  
  1. Suppose you have the same previous sample file and you run the following command:
$ sed '2i\inserted text/w outputfile' myfile  

How many lines will be saved to the output file?