LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-21-2013, 10:16 PM   #1
casperdaghost
Member
 
Registered: Aug 2009
Posts: 349

Rep: Reputation: 16
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";
 
Old 09-21-2013, 10:47 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
sed accepts address ranges as per the doco (lose the "cat" as well)
Code:
sed '3,$ s/print//g' here_doc.cgi
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Fortran 90 Open File + Skip Lines. HELP!! Saya007 Programming 4 11-02-2012 11:32 AM
[SOLVED] FTP output, dont skip lines ted_chou12 Linux - Newbie 1 04-02-2011 06:58 AM
how to skip 5 lines notoriouskingpin Linux - Newbie 2 03-12-2009 01:09 PM
Sed command to print matching lines and 2 lines above.. DX398 Programming 12 10-01-2008 08:25 AM
awk/gawk/sed - read lines from file1, comment out or delete matching lines in file2 rascal84 Linux - General 1 05-24-2006 09:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration