Need to extract daily files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to extract daily files
# 1  
Old 08-09-2005
Need to extract daily files

Hi,
I want to print my log separately for each day it contains;
-1st solutions was:
grep "^\[*" file1.log | awk '{print $1}' >> $1day.log
but I noticed that awk doesn't eat records that have more than 99 fields, so I get the error "... too many fields; Broken pipe. "
-2nd one:
grep "^\[*" file1.log | sed -n <pattern> >> day.log

problem: how to identify each day in sed separately ?

file1.log comes from IBM WebSphere and looks like:

[20/07/05 mm:dd hh:MM] ...

.. Smilie many thanks from Rome.

Carmen
Hi,
I want to print my log separately for each day it contains;
-1st solutions was:
grep "^\[*" file1.log | awk '{print $1}' >> $1day.log
but I noticed that awk doesn't eat records that have more than 99 fields, so I get the error "... too many fields; Broken pipe. "
-2nd one:
grep "^\[*" file1.log | sed -n <pattern> >> day.log

problem: how to identify each day in sed separately ?

file1.log comes from IBM WebSphere and looks like:

[20/07/05 mm:dd hh:MM] ...

.. Smilie many thanks from Rome.

Carmen
# 2  
Old 08-09-2005
Why do you want to use grep with sed ?

Just use a sed and print those lines which contain the regex.


Code:
DATE=20/07/05

sed -n -e "/[${DATE}.*/p" file1.log > ${DATE}.log

For the next date, DATE should be updated.

Vino
# 3  
Old 08-09-2005
Vino,
response from SunOS 5.8 is

sed: command garbled: /[20/07....

Vino=Wine here.
# 4  
Old 08-09-2005
Try this.

I escaped the [ and made sed look for a [ at the beginning of the string.

Code:
sed -n -e "/^\[${DATE}.*/p" file1.log > ${DATE}.log

Vino
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

2. Shell Programming and Scripting

Script to count files on daily basis

Hi all I need to count files on a daily basis and send the output via email, what I am currently doing its simply running the following:ls -lrt *.cdr | awk '{if(($6 == "Jul") && ($7 == "13")) print $0}' | wc -l, which in this case it will count all files with extension "cdr" from the month of... (13 Replies)
Discussion started by: fretagi
13 Replies

3. Shell Programming and Scripting

Bash for checking and copy Daily files and send an email

Hello, Trying to get a bash for files received on daily basis and want to copy those files to different directory and send an email notification if file exists then send the file counts else Alert with no file received. FileName format: DailyTransaction_2015-03-09_ 200.csv before 200 their is... (1 Reply)
Discussion started by: krux_rap
1 Replies

4. Shell Programming and Scripting

Check daily files arrival in a directory

Hi All, I wanted to write a script to check if set of files exist in a directory or not for a particular day. each file has a date stamp. Now i want to implement this - -i can check files of a particular date in a particular folder -generate log and send it to through email. Big THANKS !!... (5 Replies)
Discussion started by: flagboy2014
5 Replies

5. UNIX for Dummies Questions & Answers

Tracking the script(.sh) files triggered on daily or monthly basis from source

Hi Gurus, Is there any solution for tracking the script(.sh) files triggered on daily or monthly basis from source - Datastage (Routines) Needs to find out if this scripts are running on daily just want to know that is there anything to track Thanks in Advance (2 Replies)
Discussion started by: SeenuGuddu
2 Replies

6. Shell Programming and Scripting

Validate input files daily

We have a job which we need to run on daily bases, before loading data in a table we need to validate whether the input file is received or not. Daily client will place the files in a particular path.Below files which I need to process for 04/01/2013(Load date).... (2 Replies)
Discussion started by: katakamvivek
2 Replies

7. Shell Programming and Scripting

need a shell script to extract the files from source file and check whether those files existonserve

Hi, I am new to shell scripting.Please help me on this.I am using solaris 10 OS and shell i am using is # echo $0 -sh My requirement is i have source file say makefile.I need to extract files with extensions (.c |.cxx |.h |.hxx |.sc) from the makefile.after doing so i need to check whether... (13 Replies)
Discussion started by: muraliinfy04
13 Replies

8. Shell Programming and Scripting

How to extract data from indexed files (ISAM files) maintained in an unix server.

Hi, Could someone please assist on a quick way of How to extract data from indexed files (ISAM files) maintained in an UNIX(AIX) server.The file data needs to be extracted in flat text file or CSV or excel format . Usually we have programs in microfocus COBOL to extract data, but would like... (2 Replies)
Discussion started by: devina
2 Replies

9. Shell Programming and Scripting

Automate daily FTP files

How to automate FTP files daily with the following constraints 1) Try (every 15 mins or 30 mins) FTP till it reconnects 2) Files that arrive in between 5:30 pm and 2:00 am 3) The sat and sun, mon files are to be FTP on monday. 4) Only the txt files are to be FTP'ed. The following are the... (2 Replies)
Discussion started by: bobbygsk
2 Replies

10. Shell Programming and Scripting

Zip all the files within a directory on a daily basis

I need to zip all the files within a directory on a daily basis and store them as a zip file within that directory with the date in its naming convention I have file extentions .log .lst and .out's within that directory How do i do this task zip -mqj mydir/allzip$YYMMDDDD.zip mydir/*.* ... (5 Replies)
Discussion started by: ramky79
5 Replies
Login or Register to Ask a Question