The UNIX and Linux Forums  

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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script required to get a required info from file. Pls. help me. ntgobinath Shell Programming and Scripting 2 05-31-2008 05:34 AM
Script Required Satadru Shell Programming and Scripting 1 05-08-2008 09:38 AM
Script required ntgobinath Shell Programming and Scripting 1 05-08-2008 08:35 AM
script required skyineyes Shell Programming and Scripting 13 06-26-2007 10:49 PM
Script help required! kev112 Shell Programming and Scripting 8 05-24-2005 01:33 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 10-17-2005
Registered User
 

Join Date: Aug 2005
Posts: 28
help required in writing the script

Hi All,

Please help me in writting the script
File contains:
=========

11424444, <basicpage>
jfalfksf
<dateofbirth>10/02/2005</dateofbrith>
jkaklgja
lg'd
....
11423224444, <basicpage>
jfalfksf
<dateofbirth>11/02/2005</dateofbrith>
jkaklgja
lg'd
11433523224444, <basicpage>
jfalfksf
<dateofbirth>09/03/2005</dateofbrith>
jkaklgja
lg'd
<dateofbirth>09/03/2005</dateofbrith>

.........
.....


output in 1.txt
======
11424444, <basicpage>
<dateofbirth>10/02/2005</dateofbrith>

output in 2.txt
==========
11433523224444, <basicpage>
<dateofbirth>09/03/2005</dateofbrith>
<dateofbirth>09/03/2005</dateofbrith>



Here if the dateofbrith occurence is once before the next basicpage then the output should go 1.txt file else if the dateofbrith string comes again before the next basicpage string then it should send the output to the other file say 2.txt


Thanks
satish
Reply With Quote
Forum Sponsor
  #2  
Old 10-17-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
Have a look at the rules.

(4) Do not 'bump up' questions if they are not answered promptly. No duplicate or cross-posting and do not report a post where your goal is to get an answer more quickly.

Here is your original post - Help required
Reply With Quote
  #3  
Old 10-17-2005
Moderator
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,477
Thank you. I have deleted the second one.
Reply With Quote
  #4  
Old 10-17-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
And a third one at help required in unix command/script
Reply With Quote
  #5  
Old 10-18-2005
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,249
Third duplicate thread closed.

thaduka, Please stop wasting our time by posting the same question several times. This is a question on shell scripting, so belongs in this forum. If you would like a prompt reply, it may help if you could post what you have done already.

You don't say which shell you are using. This should work for bash or ksh...
Code:
while read l
do
   case $l in
          *basicpage*) ((c=c+1)) ; f=myfile$c.txt ; [[ -s $f ]] && rm $f ;;
   esac
   case $l in
          *basicpage*|*dateofbrith*) echo "$l" >> $f ;;
   esac
done < infile
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:15 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0