05-10-2009
multiline pattern matching
Hi,
I have a file of the following from:
Afghanistan
gdpcapit|800
Akrotiri
Albania
gdpcapit|6000
now I want have the gdpcapit value next to the country when there is one like this:
Afghanistan 800
gdpcapit|800
Akrotiri
Albania 6000
gdpcapit|6000
How do I do this? I've been searching for this all day...
On the machine i'm working on there is no grep that supports -B or -A... there should be a gawk or gsed though
thanks in advance
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I have file 1.txt with following entries as shown:
0152364|134444|10.20.30.40|015236433
0233654|122555|10.20.30.50|023365433
**
**
**
In file 2.txt I have the following entries as shown:
0152364|134444|10.20.30.40|015236433
0233654|122555|10.20.30.50|023365433... (4 Replies)
Discussion started by: imas
4 Replies
2. Shell Programming and Scripting
Hi all,
I'm looking for some help. I have a file (very long) that is organized like below:
>Cluster 0
0 283nt, >01_FRYJ6ZM12HMXZS... at +/99%
1 279nt, >01_FRYJ6ZM12HN12A... at +/99%
2 281nt, >01_FRYJ6ZM12HM4TS... at +/99%
3 283nt, >01_FRYJ6ZM12HM946... at +/99%
4 279nt,... (4 Replies)
Discussion started by: d.chauliac
4 Replies
3. Shell Programming and Scripting
Hello!
i wanna match in a config file, one text with more than one lines, something like this:
CACHE_SIZE{
10000 M
}
I have problems with the ends of line, i think that i can match the end of the line with \n, but i can't get it
Someone can help me with the regular expression?
... (18 Replies)
Discussion started by: claw82
18 Replies
4. Shell Programming and Scripting
Hi friends,
Could you please help me to resolve the below issue.
Input file :-
<Node>
<username>abc</username>
<password>ABC</password>
<Node>
<Node>
<username>xyz</username>
<password>XYZ</password>
<Node>
<Node>
<username>mnp</username>
... (3 Replies)
Discussion started by: haiksuresh
3 Replies
5. Shell Programming and Scripting
In a LaTeX manuscript, I need to replace many occurrences of
\emph{some string}
with some string, i.e. whatever string is inside. The string inside often may extend over several lines, and there may be other occurences of curly brackets inside it. So for example
\emph{this \it{is} a... (5 Replies)
Discussion started by: sune
5 Replies
6. Shell Programming and Scripting
Dear Experts,
I need to extract specific records from one file which has multiline records.
Input file pattern is:
============
aaaaaaaa
bbbbbbbb
asdf 1234
cccccccc
dddddddd
============
aaaaaaaa
bbbbbbbb
qwer 2345
cccccccc
dddddddd (7 Replies)
Discussion started by: dhiraj4mann
7 Replies
7. Shell Programming and Scripting
I have a file that looks something like this with lots of text before and after.
Distance method: Sum of squared size difference (RST)
</data> <pairwiseDifferenceMatrix time="02/08/11 at 13:08:27">
1 2
1 448.82151 507.94231
2 ... (7 Replies)
Discussion started by: mgray
7 Replies
8. UNIX for Dummies Questions & Answers
How can I write a script that takes a cisco config file and outputs every occurrence of two, or more, pattern matches through the whole config file?
For example, out of a config file, i want to print out every line with interface, description and ip address through the whole file, and disregard... (3 Replies)
Discussion started by: knownasthatguy
3 Replies
9. Shell Programming and Scripting
Hi all,
This is my first post, so please go easy if I broke some rules. Not accustomed to posting in forums... :)
I'm looking for help on pattern matching within a multiline block and looking to highlight blocks/block-ids that do NOT contain a particular pattern.
For example an input file... (5 Replies)
Discussion started by: tirodad
5 Replies
10. Shell Programming and Scripting
'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