Help required the cut the whole contents from one file and paste it into new file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help required the cut the whole contents from one file and paste it into new file
Prev   Next
# 1  
Old 06-12-2012
Help required the cut the whole contents from one file and paste it into new file

Hi,

First of all sincere apologies if I have posted in a wrong section ! Please correct me if I am wrong !

I am very new to UNIX scripting.

Currently my problem is that I have a code file at the location /home/usr/workarea/GeneratedLogs.log :-

Code :-

Code:
(Feb 7, 571 7:07:29 AM), Setup
(Feb 7, 571 7:07:29 AM), Setup
(Feb 7, 571 7:07:29 AM), Setup
(Feb 7, 571 7:07:29 AM), Setup
(Feb 7, 571 7:07:29 AM), Setup
(Feb 8, 003 11:23:03 PM), Setup
(Feb 8, 003 11:23:03 PM), Setup
(Feb 8, 003 11:23:03 PM), Setup
(Feb 8, 003 11:23:03 PM), Setup
(Feb 9, 861 11:39:11 PM), Setup
(Feb 9, 861 11:39:11 PM), Setup
(Feb 9, 861 11:39:11 PM), Setup


Now I want to cut the contents from this file based on date i.e. I am expecting the below code in a new file at the location /home/usr/workarea/LogCopy.log

Code :-

Code:
(Feb 7, 571 7:07:29 AM), Setup
(Feb 7, 571 7:07:29 AM), Setup
(Feb 7, 571 7:07:29 AM), Setup
(Feb 7, 571 7:07:29 AM), Setup
(Feb 7, 571 7:07:29 AM), Setup


I tried with the following script :-

Code:
 find /home/usr/workarea/GeneratedLogs.log -mtime +0 -exec cp {} /home/usr/workarea/LogCopy.log \;

But this script just created a new file and copied the contents from the parent file to the new created file and deleted the parent file !

I even tried the cut command also :-

Code:
find /home/usr/workarea/GeneratedLogs.log -mtime +0 -exec cut -d: -f1,100 /home/usr/workarea/LogCopy.log \;

But this command is not working and I am not sure what is wrong with it !!!!


My requirement is to cut the contents from the parent file and paste it into a new file which will be created during runtime and the new created should also carry the timestamp !


Could anyone mind to help me in this regard !

Thanks in advance !

Last edited by methyl; 06-12-2012 at 09:05 AM.. Reason: Please use code tags for data and code samples ; changed formatting ( seemed to be editing 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

Shell script (sh file) logic to compare contents of one file with another file and output to file

Shell script logic Hi I have 2 input files like with file 1 content as (file1) "BRGTEST-242" a.txt "BRGTEST-240" a.txt "BRGTEST-219" e.txt File 2 contents as fle(2) "BRGTEST-244" a.txt "BRGTEST-244" b.txt "BRGTEST-231" c.txt "BRGTEST-231" d.txt "BRGTEST-221" e.txt I want to get... (22 Replies)
Discussion started by: pottic
22 Replies

2. Shell Programming and Scripting

How to cut a pipe delimited file and paste it with another file to form a comma separated outputfile

Hello ppl I have a requirement to split (cut in unix) a file (A.txt) which is a pipe delimited file into A1.txt and A2.txt Now I have to join (paste in unix) this A2.txt with external file A3.txt to form output file A4.txt which should be CSV (comma separated file) so that third party can... (25 Replies)
Discussion started by: etldev
25 Replies

3. Shell Programming and Scripting

Cut, replace and Paste a String from one file to another

I need to cut all the Strings in one file and Paste it in the another file in the Specific line by replacing the specific String. For Example Step 1: From the newfile.txt, i need to copy all the strings newfile.txt How are you, I am fine, How is your work newfle2.txt Hello david,... (2 Replies)
Discussion started by: Padmanabhan
2 Replies

4. Shell Programming and Scripting

Need to cut a some required data from file

Data_Consolidation_Engine_Part_2_Job2..TgtArBkt: ORA-00942: table or view does not exist I have some thing like above in the file.. Upto this portion Data_Consolidation_Engine_Part_2_Job2..TgtArBkt: the length can be vary .. Can some one help me in taking this portion alone ORA-00942:... (7 Replies)
Discussion started by: saj
7 Replies

5. Shell Programming and Scripting

Cut and paste data in new file

HI Guys, I have file A: Abc XyZ Abc Xyz Kal Kaloo Abc XyZ Abc Xyz Kalpooo Abc XyZ Abc Xyz Kloo Abc Abc Klooo I want file B Abc XyZ Abc Xyz Kal Kaloo Abc XyZ Abc Xyz Kalpooo Abc XyZ Abc Xyz Kloo File A is now 1 lines Abc Abc Klooo Cut all lines which have xyz... (2 Replies)
Discussion started by: asavaliya
2 Replies

6. Shell Programming and Scripting

Replace partial contents of file with contents read from other file

Hi, I am facing issue while reading data from a file in UNIX. my requirement is to compare two files and for the text pattern matching in the 1st file, replace the contents in second file by the contents of first file from start to the end and write the contents to thrid file. i am able to... (2 Replies)
Discussion started by: seeki
2 Replies

7. Shell Programming and Scripting

I want to delete the contents of a file which are matching with contents of other file

Hi, I want to delete the contents of a file which are matching with contents of other file in shell scripting. Ex. file1 sheel,sumit,1,2,3,4,5,6,7,8 sumit,rana,2,3,4,5,6,7,8,9 grade,pass,2,3,4,5,6,232,1,1 name,sur,33,1,4,12,3,5,6,8 sheel,pass,2,3,4,5,6,232,1,1 File2... (3 Replies)
Discussion started by: ranasheel2000
3 Replies

8. UNIX for Dummies Questions & Answers

Cut paste from one file to other

Hello, I am working on unix for the first time. I have to write a shell script where i want to cut paste from one file to other. File "1234.abc" is 03,12345555 16,936,x,x,120 16,936,x,x,100 49,12345555 03,12347710 16,936,x,x,115 16,936,x,x,122 49,12347710 03,12342222... (9 Replies)
Discussion started by: swapsb
9 Replies

9. UNIX for Dummies Questions & Answers

compare 2 file contents , if same delete 2nd file contents

Give shell script....which takes two file names as input and compares the contents, is both are same delete second file's contents..... I try with "diff"...... but confusion how to use "diff" with if ---else Thanking you (5 Replies)
Discussion started by: krishnampkkm
5 Replies

10. Shell Programming and Scripting

File contents required for emailing.

I have created three SQL scripts that are run by one central script. What I need to do is verify the output file from the three SQL scripts(KSH Scripts) is worth emailing. This I would like to do by verifiying the contents of the result file. The contrlooing script creates the result file... (6 Replies)
Discussion started by: jagannatha
6 Replies
Login or Register to Ask a Question