LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   sed skip operating on some lines (https://www.linuxquestions.org/questions/linux-newbie-8/sed-skip-operating-on-some-lines-4175478050/)

casperdaghost 09-21-2013 10:16 PM

sed skip operating on some lines
 
I wanted to take out the print statements

Code:


ubuntu@ubuntu-VirtualBox:/usr/lib/cgi-bin$ cat here_doc.cgi
#!/usr/bin/perl
print "Content-type: text/html";
print "\n\n";
print "<html>\n";
print "<head>\n";
print "<title>Doing all this typing sucks</title>\n";
print "</head>\n";
print "<body>\n";

print "<h2>Hello World<h2>\n";
print "</body></html>\n";

so here we go - get rid of statements, however would like to save some print statements.
Code:

ubuntu@ubuntu-VirtualBox:/usr/lib/cgi-bin$ cat here_doc.cgi | sed 's/print//g'
#!/usr/bin/perl
 "Content-type: text/html";
 "\n\n";
 "<html>\n";
 "<head>\n";
 "<title>Doing all this typing sucks</title>\n";
 "</head>\n";
 "<body>\n";

 "<h2>Hello World<h2>\n";
 "</body></html>\n";

is there way to just skip switching the print statement for the first three lines - I was looking for this output
Code:

#!/usr/bin/perl
print "Content-type: text/html";
print "\n\n";
 "<html>\n";
 "<head>\n";
 "<title>Doing all this typing sucks</title>\n";
 "</head>\n";
 "<body>\n";

 "<h2>Hello World<h2>\n";
 "</body></html>\n";


syg00 09-21-2013 10:47 PM

sed accepts address ranges as per the doco (lose the "cat" as well)
Code:

sed '3,$ s/print//g' here_doc.cgi


All times are GMT -5. The time now is 10:41 AM.