Copy part of file between two strings to another


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Copy part of file between two strings to another
# 1  
Old 11-01-2012
Copy part of file between two strings to another

I am a newbie to shell scripting
I have a large log file , i need to work on the part of the log file for a particular date.

Is there a way to find the first occurance of the date string and last occurance of the next day date date string and move this section to a new file.

to explain it further.
There is a file like this
-------------------
10/30/2012 some old data
10/31/2012 some data
some other lines without date
10/31/2012 some more data
11/01/2012 some other data
----------------------------

I need to find a way that will return only the lines 2,3,4

So i was trying to find , if there is a way to find the section between the 1 st occurrance of 10/31/2012 and 1st occurrnace of 11/01/2012

I will also need a find a way to find the section between 11/01/2012 and end of file.
# 2  
Old 11-01-2012
Code:
sed -n '/10\/31\/2012/,/10\/31\/2012/p' file

Code:
sed -n '/11\/01\/2012/,/$/p' file

This User Gave Thanks to Yoda For This Post:
# 3  
Old 11-01-2012
I am getting the following error on sed command
This generating the following error

[2012-11-01 02:08:39,943 | ERROR | WebContainer : 3 | | MRF - Report UI] Print Requestor is not setup for user =B05SQMplease setup it.

Can anyone tell what it the resolution for this
# 4  
Old 11-05-2012
It s working for a different user
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help in UNIX shell to copy part of file name to new file name

Hi, I want to do the following in a Unix shell script and wonder if someone could assist me? I want to take files in a specific directory that start with the name pxpur012 and copy them to the same directory with the file name not containg pxpur012. For example, I have files like... (4 Replies)
Discussion started by: lnemitz
4 Replies

2. UNIX for Dummies Questions & Answers

Hoe to copy selected strings from file into another text file

Hi Experts, I just want to copy some selected strings from a a file into a new .txt file . I am using below command to find the data now want to copy the search results into another .txt file please help me . find /Path -exec grep -w "filename1|filename1|filename1|" '{}' \;... (2 Replies)
Discussion started by: mumakhij
2 Replies

3. UNIX for Dummies Questions & Answers

Copy the last part since the file has been updated

Input File1 constatntly running and growing in size. My Program Erorr ddmmyy hh:mm:ss My Program Error **Port 123 terminated **ID PIN 12345 Comamnd Successful Command Terminated Command Successful Command Terminated **My Program Erorr ddmmyy hh:mm:ss My Program Error **Port 345... (3 Replies)
Discussion started by: eurouno
3 Replies

4. UNIX for Dummies Questions & Answers

Copy a part of file

Hi, I want to copy text between expressions ">bcr1" and ">bcr2" to another file. Any simple solutions? Thanks (4 Replies)
Discussion started by: alpesh
4 Replies

5. Shell Programming and Scripting

Copy part of a variable

Hi, i was using a input file to get the last line of the file.But now i have stored the values from the file to a variable and want the last line from the variable . Slightly confused on how to extract that data from the variable. previous code, cat input.txt <TIME>00:15:48</TIME>... (2 Replies)
Discussion started by: Shellslave
2 Replies

6. Shell Programming and Scripting

Perl or Awk script to copy a part of text file.

Hi Gurus, I'm a total newbie to Perl and Awk scripting. Let me explain the scenario, there is a DB2 table with 5 columns and one of the column is a CLOB datatype containing XML. We need all the 4 columns but only a portion of string from the XML column. We decided to export DB2 table to a .del... (26 Replies)
Discussion started by: asandy1234
26 Replies

7. Shell Programming and Scripting

Search multiple strings on a file and copy the string next to it

I tried awk for this, but failed <or my code is not correct? I dont know>. Can anyone help me on this? ---------- Post updated at 08:34 PM ---------- Previous update was at 08:29 PM ---------- my working file looks like this: <empty> <empty> <empty> NAME :ABC AGE :15 GENDER... (6 Replies)
Discussion started by: kingpeejay
6 Replies

8. Shell Programming and Scripting

Search for strings & copy to new file

Hi All, I am just learning shell programming, I need to do the following in my shell script. Search a given log file for two\more strings. If the the two\more strings are found then write it to a outputfile else if only one of the string is found, write the found string in one output... (2 Replies)
Discussion started by: amitrajvarma
2 Replies

9. UNIX for Dummies Questions & Answers

Can I copy only part of my file to a new file?

Hi, I am looking for command to allow me only copying certain lines of records in my file to a new file. Can I do that? (3 Replies)
Discussion started by: whatisthis
3 Replies

10. Programming

How can you copy strings?

Running into a bit of difficulty making duplicates of strings that enter the program via the command line. Evidently char p = q; doesn't work, and I can't do this: for( i=0 ; q != EOF ; i++ ) p = q; as the string I'm trying to duplicate comes from the command line, from argv, so I can't... (3 Replies)
Discussion started by: area
3 Replies
Login or Register to Ask a Question