Sponsored Content
Top Forums Shell Programming and Scripting Need help in retrieving log from a UNIX file using the search patterns Post 302486033 by methyl on Thursday 6th of January 2011 07:24:48 PM
Old 01-06-2011
One way of tacking this task. First find the line number of the match on "Transaction ID" then pass through the original file looking for the lines before, equal, and after the the match.

Code:
mylogfilename="/path/mybiglogfilename"

TAB="`echo \0011`"      # Tab character
mytransaction_id="000000000000000"
cat -n "${mylogfilename}" | grep "${mytransaction_id}" | awk '{print $1,$2}'| while read mylineno mydata
do
      mylineno_before=`expr ${mylineno} - 1`
      mylineno_after=`expr ${mylineno} + 1`
      sed -n "${mylineno_before},${mylineno_after} p" ${mylogfilename}
done

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to parameterize multiple search patterns and generate a new file

I have one file: 123*100*abcd*10 123*101*abcd*-29*def 123*100*abcd*-10 123*102*abcd*-105*asd I would like to parameterize the search patterns in the following way so that the user could dynamically change the search pattern. *100* and *- (ie *minus) *102* and *- The output that is... (6 Replies)
Discussion started by: augustinep
6 Replies

2. Shell Programming and Scripting

Perl - How to search a text file with multiple patterns?

Good day, great gurus, I'm new to Perl, and programming in general. I'm trying to retrieve a column of data from my text file which spans a non-specific number of lines. So I did a regexp that will pick out the columns. However,my pattern would vary. I tried using a foreach loop unsuccessfully.... (2 Replies)
Discussion started by: Sp3ck
2 Replies

3. Shell Programming and Scripting

Retrieving values from tab-delimited file in unix script

Hi I am trying to retrieve values from a tab-delimited file.I am using while read record value=`echo $record | cut -f12` done Where 12 is the column no i want retieve and record is one line of the file. But it is returning the full record. Plz help (4 Replies)
Discussion started by: akashtcs
4 Replies

4. Shell Programming and Scripting

to read two files, search for patterns and store the output in third file

hello i have two files temp.txt and temp_unique.text the second file consists the unique fields from the temp.txt file the strings stored are in the following form 4,4 17,12 15,65 4,4 14,41 15,65 65,89 1254,1298i'm able to run the following script to get the total count of a... (3 Replies)
Discussion started by: vaibhavkorde
3 Replies

5. Shell Programming and Scripting

reading lines from a file between two search patterns

Hi, I am new to shell scripting and is working on a script to extract lines from a log file between two time stamps using awk command. After some research I used following command: awk '/01 Oct 2011/{p=1} /10 Oct 2011/{p=0} p' test.log >> tmp.log This works fine. But now i want to... (3 Replies)
Discussion started by: davidtd
3 Replies

6. Shell Programming and Scripting

How to search Multiple patterns in unix

Hi, I tried to search multiple pattern using awk trans=1234 reason=LN MISMATCH rec=`awk '/$trans/ && /'"$reason"'/' file` whenevr i tried to run on command promt it is executing but when i tried to implment same logic in shell script,it is failing i.e $rec is empty ... (6 Replies)
Discussion started by: ns64110
6 Replies

7. Shell Programming and Scripting

How to search multiple patterns and remove lines from a file?

Hi, I have a file content as below. Table : PAYR Displayed fields: 15 of 15 Fixed columns: 4 List width 0999... (4 Replies)
Discussion started by: shirdi
4 Replies

8. Shell Programming and Scripting

How to search 2 separate patterns from a 2nd file.?

Hi Guys, Need your urgent support please. I have a file with 3 separate strings separated by a comma and 2nd file which has a sentence where I can find these 3 strings. I need to find sentences which do not have these strings and maybe redirect it to a 3rd file. All the 3 strings will occur... (3 Replies)
Discussion started by: danish0909
3 Replies

9. Shell Programming and Scripting

Retrieving the relevant search from search file in the main file

I have two files: file 1: hello.com neo.com,japan.com,example.com news.net xyz.com, telecom.net, highlands.net, software.com example2.com earth.net, abc.gov.uk file 2: neo.com example.com abc.gov.uk file 2 are the search keys to search in file 1 if any of the search... (7 Replies)
Discussion started by: csim_mohan
7 Replies

10. Shell Programming and Scripting

awk search patterns from file in another

I would like to grep for aaa and bbb and ccc from one line in file1.txt in any order on a line on file2.txt file1.txt aaa bbb ccc ddd fff ggg hhh ddd jjj jjj cccfile2.txt aaa bbb ccc ddd fff ggg --> output whole line since it matches with aaa bbb ccc of file1.txt aaa ddd jjj hhh --> no... (1 Reply)
Discussion started by: sdf
1 Replies
uulog(1)						      General Commands Manual							  uulog(1)

NAME
uulog - Displays UUCP log files SYNOPSIS
/usr/lib/uucp/uulog -f system [-number] uulog uulog systems [-number] uulog -s system [-number] uulog -x [systems] The uulog command displays the contents of a log file of uucico or uuxqt activities. STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: uulog: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. OPTIONS
[Tru64 UNIX] Performs a tail -f on the file transfer log for the specified system, displaying the end of the log file. Use the Interrupt key sequence to leave the file and return to the prompt. Prints information about copy requests involving the specific system. If no sys- tem is specified, information is displayed for all systems. Note: System name can contain only ASCII characters. [Tru64 UNIX] Displays the uuxqt log file for the specified systems. If no systems are specified, information is displayed for all systems. [Tru64 UNIX] Displays the last lines of the log file. The number of lines is determined by the number argument. (To display the lines, the uulog command issues a tail for the specified number of lines.) DESCRIPTION
Individual log files are created for each remote system with which the local system communicates using the uucp, uusend, uuto, or uux com- mands. Use the uulog command to display a summary of uucp, uusend, uuto, and uux command requests by a system or systems. All of these transac- tions are logged in files under the /usr/spool/uucp/.Log/ directory. The files are named daemon_name/system, where the daemon_name direc- tory is named for the daemon involved and the system file is named for the remote system the daemon is contacting. The uucp and uuto commands call the uucico daemon. The uucico activities are logged in the system file in the /usr/spool/uucp/.Log/uucico directory. The uux and uusend commands call the uuxqt daemon. The uuxqt activities are logged in the /usr/spool/uucp/.Log/uuxqt/system file. You can examine these individual log files by issuing the uulog command directly. However, you can also have these temporary log files appended to a primary log file that you can then examine. This is called compacting the log files and is handled by uudemon.cleanu, a shell script in /usr/lib/uucp. NOTES
The uulog utility is marked LEGACY in XCU Issue 5. EXAMPLES
To display the uucico log file for system hera, enter: uulog -s hera [Tru64 UNIX] To display the uuxqt log file, enter: uulog -x [Tru64 UNIX] To display the last forty lines of the file transfer log for system zeus, enter: uulog -f zeus -40 To display the uucico log file for systems pluto and venus, enter: uulog pluto venus [Tru64 UNIX] To display the uuxqt log file for systems pluto and venus, enter: uulog -x pluto venus FILES
Contains log files. Public directory. SEE ALSO
Commands: ct(1), cu(1), tail(1), tip(1), uucico(8), uucleanup(8), uucp(1), uuencode(1), uudecode(1), uuname(1), uupick(1), uusched(8), uusend(1), uustat(1), uuto(1), uux(1) Standards: standards(5) uulog(1)
All times are GMT -4. The time now is 01:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy