07-24-2008
Joining lines and find pattern
I have a file that does not have much formatting. I would like every time it finds a tag (something that starts with < and end with > like <Tag1> ) to be at the beginning of the line and joined with the next line. I tried sed with append and can not get it right and also hold and get in sed without luck.
Ex. I have a file that look something like this:
I need to send you a file today and I
need to talk to you. <Tagger1> Ok, send
me the file. <Tag2> I will if you can give
me an address. <Ttt3> I will give you
an address as soon as I can talk
to Mark in shipping. <Tagg2> Alright talk
to Mark and get back to me. <Taggg4> Ok,
will do. <Tagger4> I talk to Mark. <Tg4> What
did he say?. <Tagger3> He gave me the business
address.
It should look like this:
I need to send you a file today and I
need to talk to you.
<Tagger1> Ok, send me the file.
<Tag2> I will if you can give me an address.
<Ttt3> I will give you an address as soon as I can talk
to Mark in shipping.
<Tagg2> Alright talk to Mark and get back to me.
<Taggg4> Ok, will do.
<Tagger4> I talk to Mark.
<Tg4> What did he say?.
<Tagger3> He gave me the business address.
Any suggestion on how to search and join lines and separate tags onto it's line would be appreciated.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I've got a log file, of the format
Name: network1
Dropped packets: 15618
Dropped packets for IPv6: 27
Dropped packets: 74
Dropped packets for IPv6: 0
Failed RADIUS Authentication procedures: 0
Failed RADIUS Accounting procedures: 0
Name: network2
Dropped packets: 1117
... (18 Replies)
Discussion started by: Yorkie99
18 Replies
2. Shell Programming and Scripting
Hi Guys,
Was trying to attempt the below using awk and sed, have no luck so far, so any help would be appreciated.
Current Text File: The first line has got an "\n", and the second line has got spaces/tabs then the word and "\n"
TIME SERVER/CLIENT TEXT... (6 Replies)
Discussion started by: eo29
6 Replies
3. Shell Programming and Scripting
My file goes like this:
SID_LIST_HOSTNAME_LISTENER_3 =
(SID_LIST =
(SID_DESC =
(SID_NAME = ORA0008)
(ORACLE_HOME = /opt/oracle/product/ORA0008)
(ENVS = "LD_LIBRARY_PATH=/opt/oracle/product/ORA0008/lib")
)
(SID_DESC =
(SID_NAME = ORA0007)
... (4 Replies)
Discussion started by: jpsingh
4 Replies
4. Shell Programming and Scripting
Hi all,
I'd like to search a file for the first occurence of the phrase "PLASTICS THAT EXPIRE" and then discard all the lines that came before it. Output the remainder to a new file. Operating system is hp-ux. I've searched for usual awk and sed one liners but can't find a solution.
Thank... (4 Replies)
Discussion started by: Scottie1954
4 Replies
5. UNIX for Dummies Questions & Answers
I need to search for two patterns in a file and find number of matching lines.
find . -type f | xargs grep "DROP TABLE" | wc -l
find . -type f | xargs grep "DROP SYNONYM" | wc -l
The above code works. However I am looking at finding a commnd that will simplify as on a singe command... (2 Replies)
Discussion started by: Siva SQL
2 Replies
6. Shell Programming and Scripting
Using grep I can easily use:
cvs log |grep -iB 10 -A 10 'date: 2013-10-30'
to display search results and 10 lines before and after. How can this be accompished using gawk? (4 Replies)
Discussion started by: metallica1973
4 Replies
7. Shell Programming and Scripting
Hi, hope you can help me... It seems like a straightforward problem, but I haven't had any success so far using my basic scripting and awk "skills":
I need to find a pattern /VEL/ in an input file that looks like this:
1110SOL OW25489 1.907 7.816 26.338 -0.4365 0.4100 -0.0736
... (3 Replies)
Discussion started by: origamisven
3 Replies
8. Shell Programming and Scripting
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
9. Shell Programming and Scripting
Dear gurus,
Please help this beginner to write and understand the required script. I am looking for useing awk for sed.
I have a few thousand lines file whose contain are mostly as below and I am trying to achieve followings.
1. Find a string, say user1. Then hash the line containing the... (6 Replies)
Discussion started by: ran_bon_78
6 Replies
10. Shell Programming and Scripting
Hi,
I need help to grep a specific part of a log file (bold).
24/2/2017-16:57:17.056 frosti-1 M3UA-Tx: }
24/2/2017-16:57:17.056 frosti-1 M3UA-Tx: extensionContainer <Not Present>
24/2/2017-16:57:17.056... (8 Replies)
Discussion started by: vasil
8 Replies