sed to remove next 15 lines after pattern in Solaris


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed to remove next 15 lines after pattern in Solaris
# 1  
Old 01-09-2018
sed to remove next 15 lines after pattern in Solaris

Team,

I am trying to use sed to delete 15 lines, after pattern patch, which includes the pattern as well in Solaris. I used the below command, as we do it Linux, but it's not working as expected in Solaris.

I am getting the error as "garbled".
Code:
sed '/\/table/,+15d' status.html
sed: command garbled: /\/table/,+15d

Any help would be really appreciated.

For example, below are the lines, and I need to delete the lines from </table>, till table border='1' width='90%' align='center' summary='Script output'>

Code:
...........................................
...........................................
...........................................
09-JAN-2018 02:00
</td>
<td align="right">
       211
</td>
<td>
SYNC
</td>
</tr>
</table>
<p>

</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta name="generator" content="SQL*Plus 11.2.0">
<style type='text/css'> body {font:10pt Arial,Helvetica,sans-serif; color:black; background:White;} p {font:10pt Arial,Helvetica,sans-serif; color:black; background:White;} table,tr,td {font:10pt Arial,Helvetica,sans-serif; color:Black; background:#f7f7e7; padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;} th {font:bold 10pt Arial,Helvetica,sans-serif; color:#336699; background:#cccc99; padding:0px 0px 0px 0px;} h1 {font:16pt Arial,Helvetica,Geneva,sans-serif; color:#336699; background-color:White; border-bottom:1px solid #cccc99; margin-top:0pt; margin-bottom:0pt; padding:0px 0px 0px 0px;-
} h2 {font:bold 10pt Arial,Helvetica,Geneva,sans-serif; color:#336699; background-color:White; margin-top:4pt; margin-bottom:0pt;} a {font:9pt Arial,Helvetica,sans-serif; color:#663300; background:#ffffff; margin-top:0pt; margin-bottom:0pt; vertical-align:top;}</style><title>SQL*Plus Report</title>
</head>
<body>
<p>
<table border='1' width='90%' align='center' summary='Script output'>
<tr>
<td>
PROD
</td>

SO, the output should be something like this.


Code:
09-JAN-2018 02:00
</td>
<td align="right">
       211
</td>
<td>
SYNC
</td>
</tr>
<td>
PROD
</td>
.................................
.................................
.................................

Please let me know if you need more details.

Last edited by MadeInGermany; 01-09-2018 at 01:12 PM.. Reason: Added CODE tags; one more
# 2  
Old 01-09-2018
Please wrap your code, files, input & output/errors in CODE tags.

It works fine for me (CentOS6) but perhaps mine is not too strict on the command formation. As a first stab, do you perhaps need a space between +15 and d?



Robin
# 3  
Old 01-09-2018
Hi Robin,

Thank you for the response.

Please note that I do not have space between +15 and d.

Regards,
Nagaraj R.
# 4  
Old 01-09-2018
The Solaris sed man page doesn't mention the "incremental" second address (as opposed to e.g. FreeBSD or linux)
# 5  
Old 01-09-2018
So, you meant to say, I can not achieve, what I am looking for using sed

Last edited by rbatte1; 01-09-2018 at 10:06 AM.. Reason: Changed CODE tags to ICODE
# 6  
Old 01-09-2018
Code:
/usr/xpg4/bin/sed '/\/table/,+15d' status.html

# 7  
Old 01-09-2018
Hi rdrtx1,

Nope. The below is not working, as expected.

Code:
/usr/xpg4/bin/sed '/\/table/,+15d' status.html

Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 01-09-2018 at 09:29 AM.. Reason: Added CODE tags.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

awk with sed to combine lines and remove specific odd # pattern from line

In the awk piped to sed below I am trying to format file by removing the odd xxxx_digits and whitespace after, then move the even xxxx_digit to the line above it and add a space between them. There may be multiple lines in file but they are in the same format. The Filename_ID line is the last line... (4 Replies)
Discussion started by: cmccabe
4 Replies

2. UNIX for Beginners Questions & Answers

awk to remove pattern and lines above pattern

In the awk below I am trying to remove all lines above and including the pattern Test or Test2. Each block is seperated by a newline and Test2 also appears in the lines to keep but it will always have additional text after it. The Test to remove will not. The awk executed until the || was added... (2 Replies)
Discussion started by: cmccabe
2 Replies

3. Shell Programming and Scripting

[sed] Finding and sticking the pattern to the beginning of successive lines up to the next pattern

I have a file like below. 2018.07.01, Sunday 09:27 some text 123456789 0 21 0.06 0.07 0.00 2018.07.02, Monday 09:31 some text 123456789 1 41 0.26 0.32 0.00 09:39 some text 456789012 1 0.07 0.09 0.09 09:45 some text 932469494 1 55 0.29 0.36 0.00 16:49 some text 123456789 0 48 0.12 0.15 0.00... (9 Replies)
Discussion started by: father_7
9 Replies

4. Shell Programming and Scripting

How to remove the lines with this pattern?

Hello everyone, I have a sample data like this: Glyma.10G051100 Glyma.02G036000 89.91 228 23 0 1 228 1 228 1e-78 294 Glyma.10G051100 Glyma.09G023700 87.28 228 29 0 1 228 1 228 1e-68 261 Glyma.10G285200 Glyma.20G103800 96.33 1663 55 4 1 1657 1 1663 0.0 2728 Glyma.10G285200 Glyma.05G093700 95.02... (2 Replies)
Discussion started by: nengcheng
2 Replies

5. Shell Programming and Scripting

sed Range Pattern and 2 lines before Start Pattern

Hi all, I have been searching all over Google but I am unable to find a solution for a particular result that I am trying to achieve. Consider the following input: 1 2 3 4 5 B4Srt1--Variable-0000 B4Srt2--Variable-1111 Srt 6 7 8 9 10 End (3 Replies)
Discussion started by: y2jacky
3 Replies

6. Shell Programming and Scripting

sed -- Find pattern -- print remainder -- plus lines up to pattern -- Minus pattern

The intended result should be : PDF converters 'empty line' gpdftext and pdftotext?xml version="1.0"?> xml:space="preserve"><note-content version="0.1" xmlns:/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size">PDF converters gpdftext and pdftotext</note-content>... (9 Replies)
Discussion started by: Klasform
9 Replies

7. Shell Programming and Scripting

Remove multiple lines that match pattern

Not sure how I can accomplish this. I would like to remove all interfaces that have the commands I would like to see: switchport port-security, spanning-tree portfast. One line is no problem. interface FastEthernet0/8 spanning-tree portfast interface FastEthernet0/9 spanning-tree... (4 Replies)
Discussion started by: mrlayance
4 Replies

8. Shell Programming and Scripting

Sed: printing lines AFTER pattern matching EXCLUDING the line containing the pattern

'Hi I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match. Which option is to be used to exclude the line containing the pattern? sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
Discussion started by: essem
11 Replies

9. Shell Programming and Scripting

Searching for pattern and remove the lines

Hi , I want to remove the specific pattern and remove those lines from file using shell script. i want to remove these lines <?xml version='1.0' encoding='UTF-8'?> <row_set> </row_set> my input file has content like this. file name: sample.xml <?xml version='1.0'... (4 Replies)
Discussion started by: nukala_2
4 Replies

10. Shell Programming and Scripting

sed pattern to delete lines containing a pattern, except the first occurance

Hello sed gurus. I am using ksh on Sun and have a file created by concatenating several other files. All files contain header rows. I just need to keep the first occurrence and remove all other header rows. header for file 1111 2222 3333 header for file 1111 2222 3333 header for file... (8 Replies)
Discussion started by: gary_w
8 Replies
Login or Register to Ask a Question