edit a file using ksh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting edit a file using ksh
# 1  
Old 04-15-2008
edit a file using perl

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. I want the format to be ..

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

Note: in the thread it says using "ksh" .. but i need it using perl .. sorry abt that..

Thanks

Last edited by DukeNuke2; 04-16-2008 at 04:55 AM.. Reason: changed title
# 2  
Old 04-16-2008
Code:
perl -pe 's/></>\n</g' file

# 3  
Old 04-16-2008
Thanks for the reply, i am doing it in a script .. can you tell me how can i do that ..
# 4  
Old 04-16-2008
I'm not sure I understand the question.

Code:
# first half of script goes here
perl -pe 's/></>\n</g' file
# second half of script goes here

If you mean in a pipeline, that's similar, too.

Code:
first --half -of "pipeline" | perl -pe 's/></>\n</g' | second --half

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh script trying to pass a variable to edit a file

I'm trying to create a ksh script that will ask the user for the port number. $PORT1 is the variable I want to use that will contain whatever numbers the user inputs. The script would edit ports.txt file, search and delete "./serv 110.1.0.1.$PORT1 200;=3" . So if the user types 50243 then the... (5 Replies)
Discussion started by: seekryts15
5 Replies

2. Shell Programming and Scripting

ksh script to edit a file using vi editor

I was wondering if it is possible to execute a script that will remove a certain search pattern from a file and save it? Manually I would just hit escape to enter command mode then search and delete the pattern "./srv 135.0.0.1.11111 210;=1" then save & exit the file vi command to search and... (3 Replies)
Discussion started by: seekryts15
3 Replies

3. UNIX for Advanced & Expert Users

Edit file

Hi All, I have file with 200K Records and each line with 400 character. I need to edit the some part of the file. For example, i need to edit character from 115 to 125, 135to 145 and 344 to 361 Can you please anyone help me to do this? Regards, (1 Reply)
Discussion started by: balasubramani04
1 Replies

4. Shell Programming and Scripting

KSH script to run other ksh scripts and output it to a file and/or email

Hi I am new to this Scripting process and would like to know How can i write a ksh script that will call other ksh scripts and write the output to a file and/or email. For example ------- Script ABC ------- a.ksh b.ksh c.ksh I need to call all three scripts execute them and... (2 Replies)
Discussion started by: pacifican
2 Replies

5. Shell Programming and Scripting

Edit a file

I have file like cp -p /var/adm/ /tmp1/tmp1.log cp -p /var/adm/ /tmp1/tmp2.log cp -p /var/adm/ /tmp1/tmp3.log cp -p /var/adm/ /tmp1/tmp4.log I need to re-write the file like: cp -p /var/adm/tmp1.log /tmp1/ cp -p /var/adm/tmp2.log /tmp1/ cp -p /var/adm/tmp3.log /tmp1/ cp -p... (3 Replies)
Discussion started by: h_banka
3 Replies

6. Shell Programming and Scripting

Script to Edit the file content and create new file

I have a requirement, which is as follows *. Folder contains list of xmls. Script has to create new xml files by copying the existing one and renaming it by appending "_pre.xml" at the end. *. Each file has multiple <Name>fileName</Name> entry. The script has to find the first occurance of... (1 Reply)
Discussion started by: sudesh.ach
1 Replies

7. Shell Programming and Scripting

Edit value in File

I have a file oratab with entry like this SCADAG:/esitst1/oracle/product/9.2.0.8:Y I am trying to discover a way to change the 9.2.0.8 part of this to something like 10.2.0.4 as part of an upgrade script. I have tried cat /etc/oratab >>/tmp/oratab... (1 Reply)
Discussion started by: sewood
1 Replies

8. UNIX for Dummies Questions & Answers

edit a .fs file

I have a .fs file that I want to edit, (or just be able to see what is in it) preferably through a windows environment. Does anyone know how to do that? Thanks (4 Replies)
Discussion started by: kiterboy
4 Replies

9. Shell Programming and Scripting

file edit help

Hi, Could anyone give me a idea how to strip the lines from a given file. example *********** 1st occurence 1st occurence 1st occurence 1st occurence *********** 2nd occurence 2nd occurence 2nd occurence 2nd occurence 2nd occurence 2nd occurence ************* 3rd occurence 3rd... (10 Replies)
Discussion started by: sentak
10 Replies

10. UNIX for Dummies Questions & Answers

file name edit

ok I have a list of files for example: 130-4-32.HindIII.0.ids 130-4-32.HindIII.0.ppm 130-4-32.HindIII.0.ppm.gz 130-4-33.HindIII.0.bands 130-4-33.HindIII.0.ics 130-4-33.HindIII.0.ids 130-4-33.HindIII.0.ppm 130-4-33.HindIII.0.ppm.gz 130-4-34.HindIII.0.bands ... (1 Reply)
Discussion started by: lorcet222
1 Replies
Login or Register to Ask a Question