The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to Append the specific data to the xml file ravi_rn Shell Programming and Scripting 2 04-03-2009 02:01 AM
Extract specific pattern from a file athreyavc Shell Programming and Scripting 4 11-12-2008 04:35 AM
serach and replace a specific pattern or value in a xml file kiranreddy1215 Shell Programming and Scripting 1 08-13-2008 12:21 PM
How to read a specific value from a Log file? cooolthud Shell Programming and Scripting 8 04-17-2008 11:30 AM
read specific text from a log file ragha81 Shell Programming and Scripting 4 10-17-2006 01:17 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 04-02-2009
kinkar_ghosh kinkar_ghosh is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 1
read from a specific pattern from one file and append it to another

Hi! Everyone,

Say this file1
--------------
line 1 51610183 420001010 0010CTCTLEDPPOO 2151610183
line 2 2151610183 420001010 0030A2TH2
line 3 2151610183 420001010 0040A2TH3
line 4 2151610183 420001010 0050A2TH4
line 5 2151610183 420001010 0060A1TD1
line 6 51610183 420001013 0010CTCTLEDPPOO 2151610183
line 7 51610183 420001013 0020A1TH1
line 8 51610183 420001013 0030A2TH2
line 9 51610183 420001013 0040A2TH3
line 10 51610183 420001013 0050A2TH4
line 11 51610183 420001013 0060A1TD1
line 12 51610183 420001013 0070A2TD2
line 13 2195410283 420001354 0010CTCTLEDPPOO 2954610183
line 14 2195410283 420001354 0020A1TH1
line 15 2195410283 420001354 0030A2TH2
line 16 2195410283 420001354 0040A2TH3
line 17 2195410283 420001354 0050A2TH4
line 18 2195410283 420001354 0060A1TD1
line 19 2195410283 420001354 0070A2TD2
line nn nnnnnnnnnn nnnnnnnnn nnnnnnnnn



I want to search in the file1 for the string '0010CTCTLEDPPOO'.
When found at line number 1, I want to append all the lines strting from line1 to the line just before the next apparance of
the string(in this example line6) to file2.
Once appendng from line 1 to line 5 is done, I want to come back to file1 again search for the next appearance for sting '0010CTCTLEDPPOO'
(in this example it is line 6) and then start appending the file2 again from line6 to line just before the next apparance of the string
'0010CTCTLEDPPOO'.(in the example it is line 13)
Likewise want to continue for the whole file1 irrespective of size.
I am facing a rare challange while writing a unix script for it.

Thanks in advance.

Regards,
Kinkar Ghosh
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:14 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0