Spliting log file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Spliting log file
# 8  
Old 08-13-2010
As per Franklin's solution, all the records present in your file will be extracted into their corresponding output files.

Suppose if you have 2009,2008,2010,2007 then you will be having four output files. And you can ignore the source file completly as all records have been considered.

Please explain your requirement more specific if this is not expected.
# 9  
Old 08-13-2010
Hello kumaran 5555,

The file i have is on live ie every time data enters to this file . This file is exceeding in size .So i have to cut the lines with last years to another file.

thanks
# 10  
Old 08-13-2010
If that is the case like a log file and logs are written by another process continuously , then you may have to consider how the log writing is implemented before discarding its content to avoid data loss.
# 11  
Old 08-13-2010
Thats ok kumaran, data loss is negligible, can we do this ? (grep+cut+paste)

thanks
# 12  
Old 08-13-2010
Quote:
Originally Posted by jobycxa
Hello kumaran 5555,

The file i have is on live ie every time data enters to this file . This file is exceeding in size .So i have to cut the lines with last years to another file.

thanks
To extract the records of 2009 you can add a condition like:
Code:
awk -F"[/:]" '$3=="2009" {print > "file_" $3}' file1

# 13  
Old 08-13-2010
The requirement is to remove it from the source file after extracting records.

The source file may have been opened by another process for logging.

The actual requirement is to keep the log file size low by archiving the logs to different files.

Please suggest.
# 14  
Old 08-13-2010
Thanks Franklin
But the source file(file1) still have the extracted data!! How could we remove it from the source file at the same time.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Requirement of Spliting a text file in UNIX Programing

Hi, There is a requirement, needs to split the text file based on RC code present in text file. For this, needs to write a unix shell programing script for the above requirement. For example in text file, if there are distinct RC codes, then we needs to split into multiple text files. In... (1 Reply)
Discussion started by: Chandra2678
1 Replies

2. Shell Programming and Scripting

Spliting file based field pattern

Hi all, i have file that looks like as below 2263881188,24570896,439,SOLO,SOLO_UNBEATABLE,E,+3.13,+0.00 2263881964,24339077,439,SOLO,SOLO_UNBEATABLE,F,-0.67,+0.00 2263883220,22619162,228,Bell,Bell_MONTHLY,E,-2.04,+0.00 2263883220,22619162,228,Bell,Bell_MONTHLY,F,-2.04,+0.00... (3 Replies)
Discussion started by: raghavendra.cse
3 Replies

3. Shell Programming and Scripting

spliting up a large file

Dear All, I have a very large file which which i would like split into indvidual frames evrytime the line ends with "ENDMDL" and then name frame1.pdb frame2.pdb etc can any one give me a few sugeestions? ideally i would like to have ENDMDL at the end of each frame or not pressent at all. an... (4 Replies)
Discussion started by: Mish_99
4 Replies

4. Shell Programming and Scripting

File Spliting problem

I have a very big log file which looks like this: I need to split this file and create files with "+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" as the delimiter. The file names need to be the contents of the next line after the delimiter(FIRST_ITEM,SECOND_ITEM...so on..). (7 Replies)
Discussion started by: engineer
7 Replies

5. UNIX for Dummies Questions & Answers

spliting a file

how would i split the file "file1" into smaller files containg lines of 15 (1 Reply)
Discussion started by: JamieMurry
1 Replies

6. Shell Programming and Scripting

Spliting a file and renaming it's out put

Hi friends, I am new to unix. With the help of this site I wrote a script. But it's returning some errors pls help.:confused: Here is my specifications: I have a file obsrec_31583_090212.xls at /home/lingalma/temp/cdl I want it to mv to another temp folder called /home/lingalma/temp/obsrec... (6 Replies)
Discussion started by: raaj.manoj
6 Replies

7. UNIX for Dummies Questions & Answers

Caching while spliting a large file

Hi The scenario is like this. I need to split 5 files having size 3GB, 2GB, 4GB, 30GB and 20 GB respectively. The machine has 15GB heap space. Before starting split proces it was showing 15gb free space. Once the split process completed it showed 100 mb free and around 12GB cached. My... (3 Replies)
Discussion started by: siba.s.nayak
3 Replies

8. Shell Programming and Scripting

Spliting the file dynamically

i am creating the file , when this file reaches the size 2 GB, i need one message or fire (4 Replies)
Discussion started by: kingganesh04
4 Replies

9. Shell Programming and Scripting

Spliting file based on condition

Hi, I have a comma separated file with millions of records in it. I have a requirement to split the file based on the value in a one of the columns. Suppose i have a text file with columns like C1, C2,C3,C4 Column C4 can hold the values either 01 or 02 03 or 04. I nned to extract... (2 Replies)
Discussion started by: Raamc
2 Replies

10. UNIX for Dummies Questions & Answers

spliting up a huge file

I have a file {filename} which contains 65000 records I need to split into 6 smaller files roughly 11000 records each. Can someone advise me of the Unix command to do so ? Many thanks (2 Replies)
Discussion started by: grinder182533
2 Replies
Login or Register to Ask a Question