Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Select text between current date and output to new txt file Post 302659983 by martin0852 on Thursday 21st of June 2012 10:25:58 PM
Old 06-21-2012
Select text between current date and output to new txt file

Hi guys,
brand new to this thread and very very new to UNIX...so go easy please!

Anyway I have a file that looks like this:

Code:
>>--------------------------------------------------------------------------
Date/Time/Eng.   : 2012-06-22 / 00:26 /   DS
Reported problem : (SD)  
------------------------------------------------------------------------------

|00:26| 

Time/Date : 2012-06-22  00:26
Status    : UP
-----------------------------------------------------------------------------<<

>>--------------------------------------------------------------------------
Date/Time/Eng.   : 2012-06-22 / 00:29 / mole  DS
Reported problem : (SD)  test
SO               :       7
------------------------------------------------------------------------------

|00:29| 

Time/Date : 2012-06-22  00:30
Status    : UP, up as up can be in sydney
-----------------------------------------------------------------------------<<

2012-06-22>>--------------------------------------------------------------------------
Date/Time/Eng.   : 2012-06-22 / 00:33 / mole  DS
Reported problem : (SD)  lotabort
SO               :       4
------------------------------------------------------------------------------

|00:33| 

Time/Date : 2012-06-22  00:33
Status    : UP
-----------------------------------------------------------------------------<<

Which will follow this formatting throughout.
The current days entries will start with the date followed by >> and end in <<

What I need to do is select the text between these two "strings" and output it to another file.
What I have tried is

Code:
sed -n '/>>/,/<</p' log.doc > outputfile.doc

(can't seem to get the date to work but ideally I want this included, but for now I am just trying to figure out something that works.)

The problem with this is I think it starts at the beginning and stops once it has hit the first instance of the two strings.....what I need is the last entered "block" of this text to be selected and output to a file that will be overwritten daily.
Is there any way to do this? I have been googling + searching this site all night but either I can't understand the methods or no-one has had this exact issue.

Any help would be greatly appreciated!

Last edited by Scrutinizer; 06-22-2012 at 02:10 AM.. Reason: code tags instead of formatting
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to create file.txt and add current date in file content

Hey guy, how to make bash script to create foo.txt file and add current date into file content and that file always append. example: today the script run and add today date into content foo.txt and tomorrow the script will run and add tomorrow date in content foo.txt without remove today... (3 Replies)
Discussion started by: chenboly
3 Replies

2. Shell Programming and Scripting

Move txt file to with current date appended to filename

I have multiple txt files which begin with the word "orders" in folder C:\source. I need to move the files to folder C:\dest and rename them to "process_<date>_<count>" So for example , if there are 3 files ordersa.txt , ordersb.txt and ordersc.txt in C:\source , after running the script I want... (1 Reply)
Discussion started by: johannd
1 Replies

3. UNIX for Dummies Questions & Answers

Move txt file to with current date appended to filename

I have multiple txt files which begin with the word "orders" in folder C:\source. I need to move the files to folder C:\dest and rename them to "process_<date>_<count>" So for example , if there are 3 files ordersa.txt , ordersb.txt and ordersc.txt in C:\source , after running the script I want... (7 Replies)
Discussion started by: johannd
7 Replies

4. UNIX for Dummies Questions & Answers

Comparing Output Date to Current System Date

Hi Guys, Anyone who knows how to compare the current date with the a file containing a date, say for example I have a file that looks like this: Command was launched from partition 0. ------------------------------------------------ Executing command in server server6 Fri Dec 16... (7 Replies)
Discussion started by: rymnd_12345
7 Replies

5. UNIX for Dummies Questions & Answers

Putting the Current -date in the Output File

Hi guys, Just want to ask how can I make a script that will perform like this. 1. Execute the command 2. Then the output of the command will be redirected to a file 2. The file that has been created will have a date on it equivalent to the date and time it was created (or maybe after the... (5 Replies)
Discussion started by: rymnd_12345
5 Replies

6. Shell Programming and Scripting

Need to append the date | abcddate.txt to the first line of my txt file

I want to add/append the info in the following format to my.txt file. 20130702|abcd20130702.txt FN|SN|DOB I tried the below script but it throws me some exceptions. <#!/bin/sh dt = date '+%y%m%d'members; echo $dt+|+members+$dt; /usr/bin/awk -f BEGIN { FS="|"; OFS="|"; } { print... (6 Replies)
Discussion started by: harik1982
6 Replies

7. Windows & DOS: Issues & Discussions

2 Questions: replace text in txt file, add text to end of txt file

so... Lets assume I have a text file. The text file contains multiple "#" symbols. I want to replace all thos "#"s with a STRING using DOS/Batch I want to add a certain TEXT to the end of each line. How can I do this WITHOUT aid of sed, grep or anything linux related ? (1 Reply)
Discussion started by: pasc
1 Replies

8. Shell Programming and Scripting

Desired output.txt for reading txt file using awk?

Dear all, I have a huge txt file (DATA.txt) with the following content . From this txt file, I want the following output using some shell script. Any help is greatly appreciated. Greetings, emily DATA.txt (snippet of the huge text file) 407202849... (2 Replies)
Discussion started by: emily
2 Replies

9. UNIX for Beginners Questions & Answers

“sed” replace date in text file with current date

We want to call a parameter file (.txt) where my application read dynamic values when the job is triggered, one of such values are below: abc.txt ------------------ Code: line1 line2 line3 $$EDWS_DATE_INSERT=08-27-2019 line4 $$EDWS_PREV_DATE_INSERT=08-26-2019 I am trying to write a... (3 Replies)
Discussion started by: pradeepp
3 Replies

10. UNIX for Beginners Questions & Answers

How to replace a parameter(variable) date value inside a text files daily with current date?

Hello All, we what we call a parameter file (.txt) where my application read dynamic values when the job is triggered, one of such values are below: abc.txt ------------------ line1 line2 line3 $$EDWS_DATE_INSERT=08-27-2019 line4 $$EDWS_PREV_DATE_INSERT=08-26-2019 I am trying to... (1 Reply)
Discussion started by: pradeepp
1 Replies
Time.localTime(3kaya)					       Kaya module reference					     Time.localTime(3kaya)

NAME
Time::localTime - Convert a time to local time. SYNOPSIS
Time localTime( Int secs=now() ) ARGUMENTS
secs The number of seconds since Jan 1 1970. This argument is optional and defaults to the current time. DESCRIPTION
Converts a time expressed in seconds since Jan 1 1970 to a Time.Time(3kaya) , using the current local timezone. AUTHORS
Kaya standard library by Edwin Brady, Chris Morris and others (kaya@kayalang.org). For further information see http://kayalang.org/ LICENSE
The Kaya standard library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (version 2.1 or any later version) as published by the Free Software Foundation. RELATED
Time.Time(3kaya) Time.gmTime(3kaya) Time.mkTime(3kaya) Time.time(3kaya) Kaya October 2012 Time.localTime(3kaya)
All times are GMT -4. The time now is 01:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy