Sponsored Content
Top Forums Shell Programming and Scripting Append text to line if begins with pattern1 AND does not end with pattern2 Post 302607472 by pioavi on Wednesday 14th of March 2012 01:38:44 PM
Old 03-14-2012
Append text to line if begins with pattern1 AND does not end with pattern2

Hello, I'm looking for sed solution to change
Code:
...
<li>keyword</li>
<li>keyword
<li>keyword</li>
<li>keyword
<li>keyword</li>
...

to
Code:
...
<li>keyword</li>
<li>keyword</li>
<li>keyword</li>
<li>keyword</li>
<li>keyword</li>
...

I.e., if lines beginning with <li> do not end with </li>, append </li> to the end.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

using sed to append text to the end of each line

Anyone know how to use SED to append a comma to the end of each line example: field1,field2,field3,field4 If i Cat /textfile ---- How can i append the end of /textfile with a comman? (8 Replies)
Discussion started by: Redg
8 Replies

2. Shell Programming and Scripting

how to delete text from line starting pattern1 up to line before pattern2?

My data is xml'ish (here is an excerpt) :- <bag name="mybag1" version="1.0"/> <contents id="coins"/> <bag name="mybag2" version="1.1"/> <contents id="clothes"/> <contents id="shoes"/> <bag name="mybag3" version="1.6"/> I want to delete line containing mybag2 and its subsequent... (5 Replies)
Discussion started by: repudi8or
5 Replies

3. Shell Programming and Scripting

grep all lines from PATTERN1 to PATTERN2

Hi! From a file like this one : hello ... PATTERN1 ... lines between patterns .. PATTERN2 ... I would like to extract only the lines between patterns, probably with awk I think? Thanks a lot for your help, Tipi (5 Replies)
Discussion started by: tipi
5 Replies

4. Shell Programming and Scripting

Sed Help.To Search Between Pattern1 And Pattern2 Containing Certain Text

Hi, Here is a sample of my Test File $ cat TestFile1 Prompt Table DQZ_ALTER_SCHEMA_ID; ALTER TABLE DQZ.DQZ_ALTER_SCHEMA_ID MONITORING; ALTER TABLE DQZ.DQZ_ALTER_SCHEMA_ID STORAGE ( NEXT 3464K ); Prompt Table DQZ_ALTER_SCHEMA_ID; ALTER TABLE DQZ.DQZ_ALTER_SCHEMA_ID MOVE LOB... (16 Replies)
Discussion started by: rajan_san
16 Replies

5. Shell Programming and Scripting

How to remove a specific line matching pattern1 and pattern2 ?

Hi, I have a file like below: . . . . Jack is going home Jack is going to school Jack is sleeping Jack is eating dinner John is going home John is eating breakfast . . . The specific line is: Jack is going home (2 Replies)
Discussion started by: salih81
2 Replies

6. Shell Programming and Scripting

Append text to end of line on all lines

Hi, I've spent some time researching for this but can't seem to find a solution. I have a file like this 1234|Test|20101111|18:00|19:00There will be multiple lines in the file with the same kind of format. For every line I need to make it this 1234|Test|20101111|18:00|19:00||create... (5 Replies)
Discussion started by: giles.cardew
5 Replies

7. Shell Programming and Scripting

delete part of file from pattern1 to pattern2

Hi all! How can I delete all the text starting from <string1> to <string2> in all the .txt files of the folder "FOLDER" ? Thanks a lot! mjomba ... </s> <s> <w></w> </s> <s> ... to get: (1 Reply)
Discussion started by: mjomba
1 Replies

8. Shell Programming and Scripting

Append text to end of every line

I've scoured the internet with mixed results. As an amateur I turn to the great minds here. I have a text file of 80 or so lines. I want to add ".pdf" to the end of each line. (For now that's it) Most of the internet points toward using "sed". I don't know coding but can figure things out... (4 Replies)
Discussion started by: spacebase
4 Replies

9. Shell Programming and Scripting

Match pattern1 in file, match pattern2, substitute value1 in line

not getting anywhere with this an xml file contains multiple clients set up with same tags, different values. I need to parse the file for client foo, and change the value of tag "64bit" from false to true. cat clients.xml <Client type"FIX"> <ClientName>foo</ClientName>... (3 Replies)
Discussion started by: jack.bauer
3 Replies

10. Shell Programming and Scripting

Get lines which has pattern1, pattern2 and pattern3 in it

Version: RHEL 6.5 In the below text file, I want to find the lines which has the string JOHN , KATE and STEVE in it. The logic is to grep with an AND condition ie. get all lines with JOHN AND KATE AND STEVE $ cat sometext.txt PHILIP worked in HR JOHN along with KATE fixed several IT... (4 Replies)
Discussion started by: John K
4 Replies
ptx(1)							      General Commands Manual							    ptx(1)

Name
       ptx - create permuted index

Syntax
       ptx [option...] [input[output]]

Description
       The  command  generates	a permuted index to file input on file output (standard input and output default).  It has three phases: the first
       does the permutation, generating one line for each keyword in an input line.  The keyword is rotated to the front.  The	permuted  file	is
       then  sorted.   Finally,  the  sorted lines are rotated so the keyword comes at the middle of the page.	The command produces output in the
       form:

	      .xx "tail" "before keyword" "keyword and after" "head"

       where .xx may be an or macro for user-defined formatting.  The before keyword and keyword and after fields incorporate as much of the  line
       as  fits  around  the keyword when it is printed at the middle of the page.  The and commands, at least one of which is an empty string "",
       are wrapped-around pieces small enough to fit in the unused space at the opposite end of the line.  When original text must  be	discarded,
       `/' marks the spot.

Options
       The following options can be applied:

       -b break 	   Use	the  characters in the break file as separators.  In any case, tab, new line, and space characters are always used
			   as break characters.

       -f		   Folds upper and lower case letters for sorting.

       -g n		   Uses specified number as interfield gap.  The default gap is 3 characters.

       -i ignore	   Do not use as keywords any words given in the ignore file.  If the -i and -o options are missing, use /usr/lib/eign	as
			   the ignore file.

       -o only		   Use words listed only in the only file.

       -r		   Uses leading nonblanks as reference identifiers.  Attach that identifier as a 5th field on each output line.

       -t		   Prepares the output for the phototypesetter.  The default line length is 100 characters.

       -w n		   Use the next argument, n, as the width of the output line.  The default line length is 72 characters.

Restrictions
       Line length counts do not account for overstriking or proportional spacing.

Files
       /usr/bin/sort
       /usr/lib/eign

																	    ptx(1)
All times are GMT -4. The time now is 04:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy