Anyways to find sentences with data format and extract it???


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Anyways to find sentences with data format and extract it???
# 1  
Old 10-30-2007
Anyways to find sentences with data format and extract it???

Hi guys,i got this problem which is..i need to find those sentences with date inside and extract them out,the input is somehow like this

eg:
$DATA42.GANTRY2.GA161147 DISKFILE 2007-10-16 11:56:45 SUPER.OPR \NETS.$Y4CB.#IN
\NETS.4,246
F DENIED READ

Report date range........: 2007-08-01 00:00 to 2007-08-01 23:59
Subject System...........: *
Subject Userid...........: *.*
Subject Login Name.......: *
Subject Terminal.........: *
Operation................: *

so what i need is the one with the date format (yyyy/mm/dd):
$DATA42.GANTRY2.GA161147 DISKFILE 2007-10-16

this line will be printed..can this be done using sed or awk????
# 2  
Old 10-30-2007
chck if this is what you want:
Code:
grep '[[:digit:]]\{4\}-[[:digit:]]\{2\}-[[:digit:]]\{2\}' filename

# 3  
Old 10-30-2007
Hi Yoguesh,well can this be done by awk or sed?i only got this two program..thanks alot!
# 4  
Old 10-30-2007
GNU awk
Code:
awk --re-interval  '
/[[:digit:]]{4}-[[:digit:]]{1,2}-[[:digit:]]{1,2}/ && !/Report/{print}' file

output:
Code:
$DATA42.GANTRY2.GA161147 DISKFILE 2007-10-16 11:56:45 SUPER.OPR \NETS.$Y4CB.#IN

i leave it to you to remove the part starting from the time till the end. give it a try
# 5  
Old 10-31-2007
Hi ghostdog,ya i managed to get the 2007-10-16 11:56:45 SUPER.OPR by using the following code

Code:
awk "/\$DATA.*DISKFILE/{print $3,$4,$5}" zyx.txt>zzz1.txt

Thanks alot for your help!!will need some more soon
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract sentence and its details from a text file based on another file of sentences

Hi I have two text files. The first file is TEXTFILEONE.txt as given below: <Text Text_ID="10155645315851111_10155645333076543" From="460350337461111" Created="2011-03-16T17:05:37+0000" use_count="123">This is the first text</Text> <Text Text_ID="10155645315851111_10155645317023456"... (7 Replies)
Discussion started by: my_Perl
7 Replies

2. Shell Programming and Scripting

Extract all the sentences from a text file that matches a pattern list

Hi I have a big text file. I want to extract all the sentences that matches at least 70% (seventy percent) of the words from each sentence based on a word list called A. Say the format of the text file is as given below: This is the first sentence which consists of fifteen words... (4 Replies)
Discussion started by: my_Perl
4 Replies

3. Shell Programming and Scripting

Extract all the sentences that matched two patterns

Hi I have two lists of patterns named A and B consisting of around 200 entries in each and I want to extract all the sentences from a big text file which match atleast one pattern from both A and B. For example, pattern list A consists of : ama ani ahum mari ... ... and pattern... (1 Reply)
Discussion started by: my_Perl
1 Replies

4. Shell Programming and Scripting

Extract data in tabular format from multiple files

Hi, I have directory with multiple files from which i need to extract portion of specif lines and insert it in a new file, the new file will contain a separate columns for each file data. Example: I need to extract Value_1 & Value_3 from all files and insert in output file as below: ... (2 Replies)
Discussion started by: belalr
2 Replies

5. Shell Programming and Scripting

Using awk to find sentences.

I am trying to print out sentences that meets a regular expression in awk (I’m open to using other tools, too). I got the regular expression I want to use, "(\+ \{4\})" from user ripat in a grep forum. Unfortunately with grep I couldn't print only the sentence. While searching for awk... (8 Replies)
Discussion started by: danbroz
8 Replies

6. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

7. Programming

How to extract a sentences of word from a text file.

Hi , i have a text file that contain a story How do i extract the out all the sentences that contain the word Mon. in C++ I only want to show those sentences that contain the word mon eg. Monkey on a tree. Rabbit jumping around the tree. I am very rich, I have lots of money. Today... (1 Reply)
Discussion started by: xiaojesus
1 Replies

8. Shell Programming and Scripting

extract specific data from xml format file.

Hi, I need to extract the start time value (bold, red font) under the '<LogEvent ID="Timer Start">' tag (black bold) from a file with the following pattern. There are other LogEventIDs listed in the file as well, making it harder for me to extract out the specific start time that I need. . .... (7 Replies)
Discussion started by: 60doses
7 Replies

9. Shell Programming and Scripting

Find term and extract till end of data

Hi All, I have an awk code below. How can i edit it such that once it finds the term "start" , it will extract all the rest of data thereafter ? awk '/start/, /stop/' file (4 Replies)
Discussion started by: Raynon
4 Replies

10. Shell Programming and Scripting

extract data from a find string

Can any one please lend a helping hand here? eg. find /tough -name temp1 -print After finding the location of all temp1 files. I need to extract some data( some are multiple others are just one entry) from each of the temp file. eg Order_Error{"aaaa") Order_Error("bbba") ... (2 Replies)
Discussion started by: odogbolu98
2 Replies
Login or Register to Ask a Question