Sponsored Content
Top Forums Shell Programming and Scripting Getting the lines between last occurrence of two patterns Post 302167327 by rvz on Thursday 14th of February 2008 05:36:38 AM
Old 02-14-2008
Getting the lines between last occurrence of two patterns

Hi
I am new shell scripting, i need help on the follwoing
I have a application log file, the application is called on cron, the log includes a "started" and "finished" lines repeatedly. I need to get the log of the for the latest run of the application.
Sample log file
Started
adfa
fadfa
Finished
Started
asdlkfjal
asfdslaj
asdfaf
afda
Finished
Started
alsfda
Finished
In this log how to do i get the lines between the last occurence of Started and Finished
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to get lines in between Patterns?

Hi, I need to create a script that does the following: 1. Read the file for the occurrences of "EXECUTE" and "END" strings. There will be several occurrences of EXECUTE and END strings on the file. 2. The resulting lines in #1, needs to be searched for the word... (11 Replies)
Discussion started by: racbern
11 Replies

2. Shell Programming and Scripting

Searching patterns in 1 file and deleting all lines with those patterns in 2nd file

Hi Gurus, I have a file say for ex. file1 which has 3500 lines in it which are different account numbers and another file (file2) which has 230000 lines in it. I want to read all the lines in file1 and delete all those lines from file2 which has that same pattern as in file1. I am not quite... (4 Replies)
Discussion started by: toms
4 Replies

3. Shell Programming and Scripting

How can I get the lines between two patterns?

hi, I have the following file hello world this is to say bye to everyone so bye I want to get the lines from hello to the first bye inclusive into another file? how can I do this (11 Replies)
Discussion started by: JamesByars
11 Replies

4. Shell Programming and Scripting

Extracting text between two patterns 1 and 2 and pattern2 should be second occurrence of the file

Hi All, I have a small query. I have a file containing the following lines File 1: 29-Jul-2011 GMT Static data requires update <Extraction should start here> ----------- ----------- -------------------- ----------------------- ----------- <should stop here> Pattern1 will be time... (2 Replies)
Discussion started by: gangii87
2 Replies

5. 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

6. Shell Programming and Scripting

[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: 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 ... (6 Replies)
Discussion started by: ppolianidis
6 Replies

7. Shell Programming and Scripting

How to output all lines following Nth occurrence of string

Greetings experts. Searched the forums (perhaps not hard enough?) - Am searching for a method to capture all output from a log file following the nth occurrence of a known string. Background: Using bash, I want to monitor my Oracle DB alert log file. The script will count the total # of... (2 Replies)
Discussion started by: cjtravis
2 Replies

8. Shell Programming and Scripting

UNIX help to print 50 lines after every 3rd occurrence pattern till end of file

I need help with extract/print lines till stop pattern. This needs to happen after every 3rd occurrence of start pattern and continue till end of file. Consider below is an example of the log file. my start pattern will be every 3rd occurrence of ERROR_FILE_NOT_FOUND and stop pattern will be... (5 Replies)
Discussion started by: NSS
5 Replies

9. UNIX for Beginners Questions & Answers

Delete multiple lines between blank lines containing two patterns

Hi all, I'm looking for a way (sed or awk) to delete multiple lines between blank lines containing two patterns ex: user: alpha parameter_1 = 15 parameter_2 = 1 parameter_3 = 0 user: alpha parameter_1 = 15 parameter_2 = 1 parameter_3 = 0 user: alpha parameter_1 = 16... (3 Replies)
Discussion started by: ce9888
3 Replies

10. UNIX for Beginners Questions & Answers

How to print lines from a files with specific start and end patterns and pick only the last lines?

Hi, I need to print lines which are matching with start pattern "SELECT" and END PATTERN ";" and only select the last "select" statement including the ";" . I have attached sample input file and the desired input should be as: INPUT FORMAT: SELECT ABCD, DEFGH, DFGHJ, JKLMN, AXCVB,... (5 Replies)
Discussion started by: nani2019
5 Replies
FMS(8)							       AFS Command Reference							    FMS(8)

NAME
fms - Determine a tape's capacity and a tape device's filemark size SYNOPSIS
fms -tape <tape special file> [-help] fms -t <tape special file> [-h] DESCRIPTION
The fms command determines the capacity of the tape currently in the tape device identified by the -tape argument, along with the size of the filemark for the device. The filemark is also referred to as the device's end-of-file (EOF) marker, and can differ for each combination of tape and tape device. As the Tape Coordinator writes a dump, it writes a filemark between the data included from each volume and also tracks the amount of space left before the end of the tape (EOT). For some tape devices, the filemark is large enough (multiple megabytes) that failure to consider it leads the Tape Coordinator significantly to overestimate the available space. The intended use of this command is to determine tape capacity and filemark size values that can be specified in a tape device's entry in the /var/lib/openafs/backup/tapeconfig file. For certain types of tape drives, the Tape Coordinator operates more efficiently when the tapeconfig file lists accurate values. For further discussion, see the OpenAFS Administration Guide chapter on configuring the Backup System. Insert a tape in the drive before issuing this command. CAUTIONS
Do not use this command on compressing tape devices in compression mode or with tape devices that handle tapes of multigigabyte (or multiterabyte) capacity. It does not produce accurate results in those cases. For alternate suggestions on the values to record in the tapeconfig file for compressing drives, see the OpenAFS Administration Guide chapter on configuring the Backup System. Running the command completely overwrites the tape, so use a blank one or one that can be recycled. Because it writes filemarks to the complete length of the tape, the command can take from several hours to more than a day to complete. OPTIONS
-tape <tape special file> Specifies the UNIX device name of the tape device for which to determine filemark size and the capacity of the tape it currently contains. The format varies on different system types, but usually begins with /dev; an example is /dev/sd0a. -help Prints the online help for this command. All other valid options are ignored. OUTPUT
The command generates output both on the standard output stream and in the fms.log file that it creates in the current working directory. The output reports the capacity of the tape in the device and the device's filemark size. The first few lines of output include status information about the execution of the command, including such information as the number of blocks and the number of file marks written to the tape by the command. The last two lines of both screen and file output provide the following information: o "Tape capacity is number bytes": specifies the size, in bytes, of the tape in the device. o "File marks are number bytes": specifies the device's filemark size in bytes. The following message indicates that the fms command interpreter cannot access the tape device. The command halts. Can't open tape drive I<device> The following message indicates that the command interpreter cannot create the fms.log log file. Again, the command halts. Can't open log file EXAMPLES
The following command illustrates the output for the device called /dev/rmt1h: % fms /dev/rmt1h wrote block: 130408 Finished data capacity test - rewinding wrote 1109 blocks, 1109 file marks Finished file mark test Tape capacity is 2136604672 bytes File marks are 1910205 bytes The following appears in the fms.log file: fms test started wrote 9230 blocks Finished file mark test Tape capacity is 151224320 bytes File marks are 2375680 bytes PRIVILEGE REQUIRED
The issuer must be able to insert and write to files in the currently working directory, if the fms.log file does not already exist. If it already exists, the issuer need only be able to write to it. SEE ALSO
fms.log(5), tapeconfig(5) COPYRIGHT
IBM Corporation 2000. <http://www.ibm.com/> All Rights Reserved. This documentation is covered by the IBM Public License Version 1.0. It was converted from HTML to POD by software written by Chas Williams and Russ Allbery, based on work by Alf Wachsmann and Elizabeth Cassell. OpenAFS 2012-03-26 FMS(8)
All times are GMT -4. The time now is 07:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy