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 edit a txt file ? RRVARMA Shell Programming and Scripting 4 05-30-2008 08:40 AM
Edit value in File sewood Shell Programming and Scripting 1 03-18-2008 02:11 AM
How to edit env file duke0001 UNIX for Advanced & Expert Users 3 02-16-2007 11:43 AM
file edit help sentak Shell Programming and Scripting 10 11-14-2006 08:20 AM
Edit an ISO / dd file? WIntellect Filesystems, Disks and Memory 4 11-20-2002 05:21 PM

Closed Thread
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
  #1 (permalink)  
Old 04-15-2008
meghana meghana is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 56
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 03:55 AM.. Reason: changed title
  #2 (permalink)  
Old 04-16-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Code:
perl -pe 's/></>\n</g' file
  #3 (permalink)  
Old 04-16-2008
meghana meghana is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 56
Thanks for the reply, i am doing it in a script .. can you tell me how can i do that ..
  #4 (permalink)  
Old 04-16-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
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
Closed Thread

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:00 AM.


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