help on a perl script to edit file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help on a perl script to edit file
# 1  
Old 05-14-2008
help on a perl script to edit file

Hi,

sample file looks like this..

<hp>
<name>
<detail>adsg</detail>
...
...
</name><ft>4264</ft>
</hp>

I need to edit the last but one line using perl script. I want the format to be ..

<hp>
<name>
<detail>adsg</detail>
...
...
</name>
<ft>4264</ft>
</hp>

Thanks
# 2  
Old 05-14-2008
Like s%</name><ft>%</name>\n<ft>% you mean?
# 3  
Old 05-14-2008
sorry i did not get your question but, all i need is to split the last but one line into 2lines ..

</name><ft>4264</ft>

CONVERT TO

</name>
<ft>4264</ft>

Please let me know if i am not clear on this.

Thanks--
# 4  
Old 05-14-2008
Maybe guess what I posted was not a question, but a snippet of Perl?
# 5  
Old 05-14-2008
oh .. is it a perl code that you are suggesting??
# 6  
Old 05-14-2008
Quote:
Originally Posted by meghana
Hi,

sample file looks like this..

<hp>
<name>
<detail>adsg</detail>
...
...
</name><ft>4264</ft>
</hp>

I need to edit the last but one line using perl script. I want the format to be ..

<hp>
<name>
<detail>adsg</detail>
...
...
</name>
<ft>4264</ft>
</hp>

Thanks
Any help on this one please .. thanks
# 7  
Old 05-14-2008
please don't bump up

please do read the rules of the forum Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

File edit script exceptions how to pass to script

i wrote script for if file exists script do file edit problem with the script get stuck not existing as for exit i mentioned exit 0 , and how to give the exception for script it should add ./script -- add hi ./script --add "hi how are you" now below script with case it is working for... (0 Replies)
Discussion started by: markjohn1
0 Replies

2. Shell Programming and Scripting

Edit a file in perl

Hi, I have a file like $ cat abc HDR XXX content XXX content YYY content XXX content YYY content XXX content YYY TRL YYYI want to replace the lines staritng with HDR and TRL For this I have written below code #!/usr/bin/perl -w use strict; open ( FH , "+< abc" ) || die "Can't... (1 Reply)
Discussion started by: sam05121988
1 Replies

3. Homework & Coursework Questions

Edit the file in shell script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I am trying to automate hadoop installation procedure using shell script. It involves go to perticular directory... (3 Replies)
Discussion started by: Abdul Navaz
3 Replies

4. Shell Programming and Scripting

shell script to edit a file

i have a file called number which contains data as 1 2 3 4 5 6 7 8 9 0 9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 needed a shell script to print the output as 1 7 7 1 4 and (2 Replies)
Discussion started by: jacky29
2 Replies

5. Shell Programming and Scripting

Shell script to edit a file

Hello, I have a big file in wich I would like to rename inside this exactly the string '_ME' and not rename in case we have 'ABC_MELANGE'. Is there a way to do it by using a shell script? Any tip will be apreciated. The file is like described bellow, after using command more filename : ... (3 Replies)
Discussion started by: Titas
3 Replies

6. Shell Programming and Scripting

perl edit file

Is there a way to edit a file without opening two files the only method I know is one file for reading from and one file writing to I cannot think of any other ways (4 Replies)
Discussion started by: 3junior
4 Replies

7. Shell Programming and Scripting

Need help in writing a script to edit a file

Hi all, I need help in writing a script to edit a file Here is the sample of my file abc xxx 123 456 789 045 def yyy 987 678 098 cdf zzz 435 543 jhg vvv 987 765 (2 Replies)
Discussion started by: leo.maveriick
2 Replies

8. Shell Programming and Scripting

Edit a line in a file with perl

Hi, How can I edit a line in a file? For example, a.txt contains: start: 1 2 3 4 stop: a b c d and I want to change "3" to "9" and to add "5" after "4" the result should be (a.txt): start: 1 9 3 4 5 stop: a b c d Thanks, zed (5 Replies)
Discussion started by: zed
5 Replies

9. Shell Programming and Scripting

How to EDIT file using VI in a script

Hello, How would i go about editing a file using VI within a shell script please? Basically, i want to open a file, clear it's contents and save the file. I found this on the web using "ex" but can't seem to get it to work: ex /home/oconnor/TOOLS/UNIXCMDS/test_ex <<eof_ex dd /*i put... (2 Replies)
Discussion started by: bobk544
2 Replies

10. Shell Programming and Scripting

Shell/Perl Script to edit dhcpd.conf

Hi, I need to get a script together to edit the dhcp service configuration file dhcpd.conf. Mac addresses are defined in classes ex. class "HOST1" { match if substring (hardware, 1,18)=00:11:11:FF:FF:FF;} class "HOST2" ... class "HOST3" ... ... followed by allow or deny statements:... (4 Replies)
Discussion started by: sahilb
4 Replies
Login or Register to Ask a Question