help required in writing the script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help required in writing the script
# 1  
Old 10-17-2005
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
# 2  
Old 10-18-2005
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
# 3  
Old 10-18-2005
Thank you. I have deleted the second one.
# 4  
Old 10-18-2005
# 5  
Old 10-18-2005
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

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help required in writing the regular expression.

1 1982 1 testing init.cc 3001 Apr 25 2014 09:56:13.617 Task(0x5bac5060) tRestart (stack st:0x5bace000, end:0x5bac8000) deleted 1 1982 1 testing init.cc 3001 Apr 25 2014 09:56:13.628 Task(0x5bac5060) tRestart (stack st:... (12 Replies)
Discussion started by: VSSajjan
12 Replies

2. UNIX for Dummies Questions & Answers

Perl Script:how to find how many parameters are required to run the script

How to find how many parameters are required to run a Perl script? (1 Reply)
Discussion started by: Lakshman_Gupta
1 Replies

3. HP-UX

Please help me writing this script

I work on a production server. I have to check one folder named "spool" and delete files under it , which are more than 5 minutes old. I do it manually by writing two commands. touch -t YYMMDDHHMMSS /tmp/timeinfo find /spool ! -newer /tmp/timeinfo -exec rm -rf {} \; I want to... (4 Replies)
Discussion started by: manalisharmabe
4 Replies

4. Shell Programming and Scripting

I need help writing this script

:wall: Can't seem to figure out how to fix this please help its not starting over like I would like it to When I enter in "Date" or "Time" nothing comes Also if you can tell me the commands for the other 3 stuff that would be much appreciated #!/bin/bash clear while ; do echo... (8 Replies)
Discussion started by: nowruzr
8 Replies

5. Shell Programming and Scripting

Please help me in writing my script

hello all, I have a script, used to search for the strings from the set of 5 similar pattern file from the log dir. So here it goes . The input parameter is a part of the file name. When during the script execution, the script should parse the input parameter to original file's with the same... (0 Replies)
Discussion started by: baraghun
0 Replies

6. Shell Programming and Scripting

Help in writing a script

Hey everyone Can anyone please write me a script to display numbers in descending order dynamically i.e if the user enter a number say 100 then the output should be like 100 99 ....so on till 0 I tried using the logic as for ((i =1; i<=100; i--) but the it goes into a infinite loop since even the... (7 Replies)
Discussion started by: icchi
7 Replies

7. Shell Programming and Scripting

Getting required fields from a test file in required fromat in unix

My data is something like shown below. date1 date2 aaa bbbb ccccc date3 date4 dddd eeeeeee ffffffffff ggggg hh I want the output like this date1date2 aaa eeeeee I serached in the forum but didn't find the exact matching solution. Please help. (7 Replies)
Discussion started by: rdhanek
7 Replies

8. UNIX for Dummies Questions & Answers

Need help writing this script

Here is the script I am trying to write along with my answer I wrote. Please help me understand why it doesn't work. Create an executable script file called "newname" that will perform the followings: 1. Rename a file upon the user's request. If the file exists, prompt the user for... (1 Reply)
Discussion started by: wiggles
1 Replies

9. UNIX for Dummies Questions & Answers

help for writing a script

Hi, I need help writing a unix script to change the time in the server automatically when it reaches a specified time. Only on the 14th of april, when the time becomes midnight (00:00:00), I need the server to change the time automatically to 23:30:00 and start working on as usual with a... (2 Replies)
Discussion started by: amodha
2 Replies

10. Shell Programming and Scripting

need help writing a script

Hello everyone. Well, I will get right to the point. I am new to Perl and trying to learn it as much as I can. I have been assigned the task of writing a perl script to extract information from firewall logs. Like I said, I am new to Perl and I am having a tough time because I think what I am... (3 Replies)
Discussion started by: tarballed
3 Replies
Login or Register to Ask a Question