Sponsored Content
Top Forums Shell Programming and Scripting [Solved] Sed/awk print between patterns the first occurrence Post 302554846 by ppolianidis on Tuesday 13th of September 2011 07:24:36 AM
Old 09-13-2011
[Solved] Sed/awk print between patterns the first occurrence

Guys,

I am trying the following:

i have a log file of a webbap which logs in the following pattern:

Code:
2011-08-14 21:10:04,535 blablabla ERROR blablabla
       bla
       bla
      bla
      bla
2011-08-14 21:10:04,535 blablabla ERROR blablabla
       bla
       bla
      bla
      bla
2011-08-14 21:10:04,535 blablabla ERROR blablabla
       bla
       bla
      bla
      bla


what i need is to print everything between the ERROR pattern but only the first occurrence :

Code:
2011-08-14 21:10:04,535 blablabla ERROR blablabla
       bla
       bla
      bla
      bla


Please help!

Last edited by pludi; 09-13-2011 at 08:42 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sed to print a string until the second occurrence of a character

Hi, I am totally new to shell scripting. I have a String "c:\working\html\index.txt.12-12-2009.bkp" I want to check if the string has more than one "." character. If it does I would like to retrieve only "c:\working\html\index.txt" i.e, discard the second occurrence of "." and the rest of the... (7 Replies)
Discussion started by: imr
7 Replies

2. Shell Programming and Scripting

Sed/awk print between different patterns the first occurrence

Thanks for the help yesterday. I have a little modification today, I am trying the following: i have a log file of a webbap which logs in the following pattern: 2011-08-14 21:10:04,535 blablabla ERROR Exception1 blablabla bla bla bla bla 2011-08-14... (2 Replies)
Discussion started by: ppolianidis
2 Replies

3. Shell Programming and Scripting

sed print from last occurrence match until the end of file

Hi, i have file f1.txt with data like: CHECK a b CHECK c d CHECK e f JOB_START .... I want to match the last occurrence of 'CHECK' until the end of the file. I can use awk: awk '/^CHECK/ { buf = "" } { buf = buf "\n" $0 } END { print buf }' f1.txt | tail +2Is there a cleaner way of... (2 Replies)
Discussion started by: ysrini
2 Replies

4. UNIX for Dummies Questions & Answers

[SOLVED] awk: matching degenerate patterns

Hi Folks, I have two arrays a: aaa bbb ccc ddd ddd aaa bbb ccc ddd ccc aaa bbb b: aaa bbb ccc aaa ccc bbb bbb aaa ccc ccc bbb aaa I want to compare row by row a(c1:c4) to b(c1:c3). If elements of 'b' match... (5 Replies)
Discussion started by: heecha
5 Replies

5. Shell Programming and Scripting

sed print between 2 patterns only last occurence

Hi, I have a file, which contains the following log data. I am trying to print fromt he file the following data: I have tried using sed, but I am getting from the first pattern Thanks for your help. (5 Replies)
Discussion started by: sol_nov
5 Replies

6. Shell Programming and Scripting

[Solved] HP-UX awk sub multiple patterns

Hi, I am using sub to remove blank spaces and one pattern(=>) from the input string. It works fine when I am using two sub functions for the same. However it is giving error while I am trying to remove both spaces and pattern using one single sub function. Working: $ echo " OK => " |awk... (2 Replies)
Discussion started by: sai_2507
2 Replies

7. Shell Programming and Scripting

Print mutliple patterns in a line using sed

Hi, I am trying to print multiple patterns in a line using sed. But it is printing only the last occurance of a pattern. If the line is the the output should be Lookup Procedure|Stored proc But the output I am getting is Stored proc The code I am using is echo... (9 Replies)
Discussion started by: kedar_laveti
9 Replies

8. UNIX for Dummies Questions & Answers

[Solved] Awk: count occurrence of each character for every field

Hi, let's say an input looks like: A|C|C|D A|C|I|E A|B|I|C A|T|I|B as the title of the thread explains, I am trying to get something like: 1|A=4 2|C=2|B=1|T=1 3|I=3|C=1 4|D=1|E=1|C=1|B=1 i.e. a count of every character in each field (first column of output) independently, sorted... (4 Replies)
Discussion started by: beca123456
4 Replies

9. Shell Programming and Scripting

awk to extract and print first occurrence of pattern in each line

I am trying to use awk to extract and print the first ocurrence of NM_ and NP_ with a : before in each line. The input file is tab-delimeted, but the output does not need to be. The below does execute but prints all the lines in the file not just the patterns. Thank you :). file tab-delimeted ... (2 Replies)
Discussion started by: cmccabe
2 Replies

10. Shell Programming and Scripting

sed print from last occurrence match until the end of last occurrence match

Hi, i have file file.txt with data like: START 03:11:30 a 03:11:40 b END START 03:13:30 eee 03:13:35 fff END jjjjjjjjjjjjjjjjjjjjj START 03:14:30 eee 03:15:30 fff END ggggggggggg iiiiiiiiiiiiiiiiiiiiiiiii I want the below output START (13 Replies)
Discussion started by: Jyotshna
13 Replies
FTE(1)							      General Commands Manual							    FTE(1)

NAME
fte - Text editor SYNOPSIS
fte [[options] files ...] xfte [[options] files ...] vfte [[options] files ...] nfte [[options] files ...] sfte [[options] files ...] DESCRIPTION
This manual page documents briefly the fte. Some detailed documentation is available html format, see below. fte is a powerful text editor which closely resembles Borlands programming editors for M$-DOS, but is far more flexible and configurable. OPTIONS
fte uses a command line syntax, which is a little bit different from most of Debian GNU/Linux apps. -h -? --help Help on command line options. -! Ignore any external configuration file and use internal configuration. -l<line>[,<column>] Go to line (and column) in next file on command line. -#<line>[<,column>] Same as -l. Do not use this option. -m[<mode>] Set mode for next files to <mode>. If just plain -m, then use default mode. -C[<.cnf>] Use specified configuration file (compiled). Plain -C does the same as -!. -D[<.dsk>] Load/save desktop from file <.dsk>. If no argument, disable desktop load/save. -H[<.his>] Load/save history from file <.his>. If no argument, disable history load/save. -T<tagfile> Load 'tagfile' at startup. -t<tag> Lookup tag 'tag' and display file containing it. -- The rest of the arguments are not options, but filenames. -+ The next argument is not an option even if starting with a '-'. Useful when loading files that begin with a -. -noi18n Do not use locales in xfte - useful if you have incorrect locales. -noxmb Do not use XMB functions in xfte - useful if you have incorrect locales and you want to use just english fonts. -font Select XWindow font to use with xfte. See VIOFONT also. ENVIRONMENTAL VARIABLES
This is list of variable which might change behavior of some internals of fte. VIOFONT - select font used by xfte ISOCONSOLE - when set, vfte is usign ascii symbols to draw tables. This is useful when iso latin charset is used on console. EXAMPLES
fte -mBIN /usr/bin/vfte load /usr/bin/vfte in BIN mode fte -mBIN -+ -bla- load file -bla- in BIN mode fte -l100,30 win.c go to (100,30) in win.c fte window.cpp load file window.cpp fte -- -1 -2 -3 -4 -5 -6 load files -1, -2, -3, -4, -5, -6 fte -D -H fte.dsk fte.his disable desktop and history loading and saving and load files fte.dsk and fte.his FILES
~/.fterc /usr/local/etc/fte/system.fterc /etc/fte/system.fterc Default configuration files. Includes all keybindings and menus compiled with cfte(1) from config files in /usr/share/doc/fte/config-exam- ple.tar.gz. SEE ALSO
cfte(1), /usr/share/doc/fte/contents.html AUTHORS
This manual page was written by Riku Voipio and Zdenek Kabelac <riku.voipio@iki.fi> <kabi@debian.org> for the Debian GNU/Linux system. DATE
18 Nov 1999 FTE(1)
All times are GMT -4. The time now is 06:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy