Perfect ! Both commands are working perfect for the example that I posted. \
But it is not working if I change the script to my actual.
Some useful points about my real logs..
1. Responses can have some names like ListABCRes, ABCRes, DDARes, etc..
where in example log I gave you response1,response2 etc ..
To get ListABCRes, I changed your command as below
Responses are big and There are too many responses for one user and too many same responses for different users say for example many users can have ListABCRes response and one user can have ListABCRes in the logs many times.
So do you suggest anything on this ?
Last edited by nariwithu; 01-20-2012 at 05:17 PM..
This is setting a variable 'resp' to have the value 'response2', and variable 'user' to a string 'user1'. Do not change the code inside the single quotes, just change the "response2" to what is your response actually named. If you are hunting a section
However, I don't see why you would be getting "record too long" error... the code is appending to an internal variable. Have you tried to preprocess the file with the sed command and then pipe it to awk as suggested before?
I am again noting that one user can have two or more ListABCResp in the logs, Logs can be big, Response can be big and Many users can have ListABCResp responses. Similarly other responses also.
I have no clue how to proceed. Hope you will help me again.
tar xvzf gawk-3.1.8.tar.gz
cd gawk-3.1.8
./configure
make
make install
If you don't have the privilege to install it system wide, just install it in a non-standard directory:
Code:
./configure --prefix=/path/to/MyDir
make && make install
---------- Post updated at 06:54 PM ---------- Previous update was at 06:34 PM ----------
Do you have perl?
Code:
r=response1 #substitute with the real name
u=user1 #substitute with the real name
sed -e '/.*<'$r'*>.*/ {x;p;x}' -e '/<\/'$r'*>/ {G}' logFile |
perl -ne '$/="\n\n"; if(/<'$r'/&&/<user>'$u'/){print;}'
Downloaded gawk-3.1.8.tar.gz Extracted in windows machine as tar was not working for me. uploaded the extracted gawk-3.1.8 folder to my directory in unix machine. ran the command ./configure make make install
I am getting the following error while installing.
Code:
./configure make && make install
configure: WARNING: you should use --build, --host, --target
checking for a BSD-compatible install... ./install-sh -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... nawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking for make-gcc... no
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/xpg4/bin/grep
checking for egrep... /usr/xpg4/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for egrep... (cached) /usr/xpg4/bin/grep -E
checking for bison... no
checking for byacc... no
checking whether ln -s works... yes
checking for make-gcc... gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking how to run the C preprocessor... gcc -E
checking whether make sets $(MAKE)... (cached) yes
checking for special development options... no
checking for z/OS USS compilation... no
checking for strerror in -lcposix... no
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... 64
checking for AIX compilation hacks... no
checking for Linux/Alpha compilation hacks... no
checking for function prototypes... yes
checking for string.h... (cached) yes
checking whether NLS is requested... yes
checking for msgfmt... no
checking for gmsgfmt... :
checking for xgettext... no
checking for msgmerge... no
checking build system type... Invalid configuration `make': machine `make' not recognized
configure: error: /bin/bash ./config.sub make failed
Quote:
Do you have perl?
I have perl installed. When I ran your suggested perl code by modifying like below, I am getting the following error.
Code:
r=ListABCResp #substitute with the real name
u=user1 #substitute with the real name
sed -e '/.*<'$r'*>.*/ {x;p;x}' -e '/<\/'$r'*>/ {G}' abc.log |
perl -ne '$/="\n\n"; if(/<'$r'/&&/<user>'$u'/){print;}'
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)
Hi all,
I have an input file as below. I would like to count the occurrence of pattern matching 8th field for each line.
Input:
field_01 field_02 field_03 field_04 field_05 field_06 field_07 field_08
TA T TA T TA TA TA... (3 Replies)
Assume a string that contains one or multiple occurrences of three different keywords (abbreviated as "kw"). I would like to replace kw2 with some other string, say "qux". Specifically, I would like to replace that occurrence of kw2 that is the first one that is preceded by kw1 somewhere in the... (4 Replies)
HPUX /bin/sh (posix)
I have a file as such
cat dog mouse
deer elk rabbit
mouse rat pig
I would like to replace the second occurrence of mouse in this file with mouse2. The rest of the file has to stay exactly as is. I'm not sure exactly where mouse might be (could be first,second,third... (5 Replies)