Although my sed skills are gradually developing, thanks in large part to this forum, I'm having a hard time dealing with pattern space and looping, which I suspect is what I'll need a better handle on to figure out my current issue, which is converting a multi line file like this:
12345678|ONE%TWO%THREE
into
12345678|ONE
12345678|TWO
12345678|THREE
The % delimited items to the right of the pipe is an unlimited range of elements. The left of the pipe will always contain an 8 digit number. My thought was to perhaps make two passes (maybe creating an intermediate file) that first just substituted the % delimiters with a pipe and carriage return, e.g.
Which would give me this...
12345678|ONE
|TWO
|THREE
Then on the next pass somehow grab just the number in the pattern space and prepend it to subsequent lines that do not begin with a number (the % delimited elements will always be alpha characters.)
And that's where I'm stuck. Any snippets or even just strategy suggestions would be greatly appreciated. Although this appears to be pretty low hanging fruit for the likes of perl, I'd like to hang with sed to the extent that it's possible... for the challenge if nothing else :-).
hi,
I'm trying to calculate IP addresses and their respective calls to our apache Server. The standard format of the input is
HOST IP DATE/TIME - - "GET/POST reuest" "User Agent"
HOST IP DATE/TIME - - "GET/POST reuest" "User Agent"
HOST IP DATE/TIME - - "GET/POST reuest" "User Agent"
HOST... (2 Replies)
Hi
I am using Solaris 5.10 & ksh
Wanted to loop through a pattern file by reading it and passing it to the awk to match that value present in column 1 of rawdata.txt , if so print column 1 & 2 in to Avlblpatterns.txt. Using the following code but it seems some mistakes and it is running for... (2 Replies)
Hi,
I've got text files (say file1 and file2) in a directory (say directory1) with several columns like this:
a b c d
a b c de f g h
e f g hI need to add a header to the files in directory1 and the names of the columns must contain an identifier from another text file (say file3) like this:... (4 Replies)
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)
Hi,
I have file which contains following lines
A| 965.|Mr.|35.45| 66.
B| 33.| a456.| 77.
The output should be
A|965|Mr.|35.45|66
B|33| a456.|77
Basically if a Number has space in prefix and . in suffix remove both.
So pattern could be if there is a | which has next two characters as... (1 Reply)
Good day.
Trying to make a sed script to take text file in a certain format and turn it into mostly formatted html.
I'm 95% there but this last bit is hurting my head finally.
Here's a portion of the text-
Budgeting and Debt:
Consumer Credit Counseling of Western PA
CareerLink
112... (5 Replies)
If the string is of the pattern XxxXyzAbc...
The expected out put from sed has to be Xxx Xyz Abc ...
eg: if the string is QcfEfQfs, then the expected output is Qcf Ef Efs.
If i try to substitute the pattern with space then the sed will replace the character or pattern with space,... (1 Reply)
Hi,
I'm new to sed and i'm having a few difficulties.. I need to append the current line to the pattern space, which already contains that same line, e.g.:
current line : test
pattern space : test|test
I was able to do this using the hold space, but the problem is that in the next step of... (2 Replies)
why does sed 's/.* //' show the last word in a line
and
sed 's/ .*//' show the first word in a line? How is that blank space before or after the ".*" being interpreted in the regex?
i would think the first example would delete the first word and the next example would delete the second... (1 Reply)
Hi guys
I having som problem trying to use sed to get a file and insert inside another one. I'll try to explain better.
I have a base.txt and using sed(having a array variables) I'm chaging some strings inside this file and saving as base1.txt. until here okay.
Then, I have to get this... (4 Replies)