read data from file from a specific duration


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting read data from file from a specific duration
# 1  
Old 10-13-2011
read data from file from a specific duration

Hi,

i have log file which keeps on updating almost ever minute but i have certain string in log which will only be displayed between specific time. so i need to search for that string and copy the details starting from that string and stop at certain string below that.
example: log file contains as below
1243
123214
wtewds
243243
starting update
1234 records updated
985 records updated
10 records updated
final update
400 records updated
update completed
df[lsfadmgld
df
asdfg
ds'g
sd'g
ds
g'sd'g
sdg
starting update
134 records updated
85 records updated
104 records updated
final update
450 records updated
update completed
mb dmnb
mflmfnbvc
svmdknb
sd,vfl;sb


i need to copy the contents of this log file starting from "starting update" till "update completed" into another file. these lines will be displayed almost 20 to 30 times in a day but i need to search for a specific duration say 6pm to 11pm and i need to copy for this duration irrespective of number of times the string are displayed.
# 2  
Old 10-13-2011
I don's see the time in your sample.

Code:
awk '/starting update/,/update completed/' yoursample.log  > another.file

# 3  
Old 10-14-2011
Thanks for the help. for the log file below can i use the same awk command. and i want the output file to include the record updated both times.

1243
123214
wtewds
243243
bla bla bla===starting update===
1234 records updated
985 records updated
10 records updated
final update
400 records updated
bla bla bla :::::::update completed::::::::
df[lsfadmgld
df
asdfg
ds'g
sd'g
ds
g'sd'g
sdg
bla bla bla===starting update===
134 records updated
85 records updated
104 records updated
final update
450 records updated
bla bla bla :::::::update completed::::::::
mb dmnb
mflmfnbvc
svmdknb
sd,vfl;sb
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

In PErl script: need to read the data one file and generate multiple files based on the data

We have the data looks like below in a log file. I want to generat files based on the string between two hash(#) symbol like below Source: #ext1#test1.tale2 drop #ext1#test11.tale21 drop #ext1#test123.tale21 drop #ext2#test1.tale21 drop #ext2#test12.tale21 drop #ext3#test11.tale21 drop... (5 Replies)
Discussion started by: Sanjeev G
5 Replies

2. Shell Programming and Scripting

How to read all data after a specific string from a text file ?

Hi, I have a file(input.txt) and trying to format as output.txt. See the attached file format. Note: This is a windows file (DOS format) and the commands are also going to execute on windows. Basically I am trying to capture all the data in between Local Group Memberships and Global Group... (10 Replies)
Discussion started by: Monoj2014
10 Replies

3. Shell Programming and Scripting

How to read data from tab delimited file after a specific position?

Hi Experts, I have a tab deliminated file as below myfile.txt Local Group Memberships *Administrators *Guests I need data in below format starting from 4th position. myfile1.txt Administrators Guests the above one is just an example and there could... (15 Replies)
Discussion started by: Litu1988
15 Replies

4. Shell Programming and Scripting

To read specific line from a file

Hi, I have a ldif file like below: version: 1 dn: cn=Test Group,ou=Applications,dc=xyz,dc=com objectClass: groupOfUniqueNames objectClass: top cn: Test Group uniqueMember: uid=abc,ou=People,o=xyz,o=Corporate,dc=xyz,dc=com dn: cn=Test Sub Group,cn=Test... (4 Replies)
Discussion started by: saurau
4 Replies

5. Shell Programming and Scripting

Read in specific lines in a file

I have a text file First title line name1 name2 name3 name4 (etc) other lines other lines other lines I want to read in this text file and parse the name1...name4 to a variable. How do I specificially read in these lines and these lines only? (10 Replies)
Discussion started by: piynik
10 Replies

6. Shell Programming and Scripting

Extracting specific lines of data from a file and related lines of data based on a grep value range?

Hi, I have one file, say file 1, that has data like below where 19900107 is the date, 19900107 12 144 129 0.7380047 19900108 12 168 129 0.3149017 19900109 12 192 129 3.2766666E-02 ... (3 Replies)
Discussion started by: Wynner
3 Replies

7. Shell Programming and Scripting

Extract specific read from a data

Input file: #abc_1 SAASFASFGGDSGDSGDSGSDGSDGSDGSDGSDGSDGSDGDS Output file: FASFGGDSGDS I just want to print out the read from position 5 until position 15 from the data. Below is the code that I just try but it is failed to get my desired output: grep -v '#' input_file | awk... (5 Replies)
Discussion started by: patrick87
5 Replies

8. Shell Programming and Scripting

Read Write byte range/chunk of data from specific location in file

I am new to Unix so will really appreciate if someone can guide me on this. What I want to do is: Step1: Read binary file - pick first 2 bytes, convert from hex to decimal. Read the next 3 bytes as well. 2 bytes will specify the number of bytes 'n' that I want to read and write... (1 Reply)
Discussion started by: Kbenipel
1 Replies

9. Shell Programming and Scripting

How to read a specific value from a Log file?

Hi, I have a .log file in which it has many values. But i need some specific values. How it can be done using Shell Script. Please explain in detail. Thankx in advance. Sathish D V. (8 Replies)
Discussion started by: cooolthud
8 Replies
Login or Register to Ask a Question