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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need Replacement for sed dbsurf Shell Programming and Scripting 0 01-25-2008 06:47 PM
Regarding Replacement rajx UNIX for Dummies Questions & Answers 2 05-22-2007 10:19 AM
String Replacement with Perl Lindarella Shell Programming and Scripting 4 09-29-2006 03:05 PM
Replacement using sed handak9 UNIX for Dummies Questions & Answers 5 07-13-2004 12:28 PM
cpu replacement. help IMPTRUE UNIX for Dummies Questions & Answers 3 07-25-2003 09:40 AM

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 01-25-2008
dbsurf dbsurf is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 23
Replacement of sed with perl

Hi using the below cmd i am identifying wheether last character in each line in thousands of files as semicolon or not.If last character is semicolon i am removing semicolon .If last character is not semicolon then i am appending next line to present line .

For example my input file consists of

ABC|FGH|HJK|JKK;
BHJ|AAA|BBB|L
NNNN|JJJJ|LLLL;
JJJJJJ;
out put file consists of
ABC|FGH|HJK|JKK
BHJ|AAA|BBB|L NNNN|JJJJ|LLLL
JJJJJ
I am achieving the above requirement using sed as below

sed -e :a -e '/;$/!N;s/\n//; ta' -e 's/;$//' file

but i have thousands of files in one directory its consuming more and more time .

Can anyone replace the above requirement in perl with xargs

like xargs perl option

cn anyone suggest the easiest way without looping
  #2 (permalink)  
Old 01-25-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,790
how about sed:

Code:
sed -e :a -e '/$;/N; s/\\\n//; s/$;//; ta'  oldfile > newfile

  #3 (permalink)  
Old 01-25-2008
dbsurf dbsurf is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 23
Hi Jim ,

The above code works with sed but it is consuming too much time ..can you provide the same with perl syntax.
THe functionality is it has to identify last character in each line of all files as semicolon.if it founds as semicolon it has to replace with blank space otherwise need to append next line with present one.
  #4 (permalink)  
Old 01-25-2008
KevinADC KevinADC is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2008
Posts: 731
see your other thread
  #5 (permalink)  
Old 01-25-2008
dbsurf dbsurf is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 23
cn anyone provide me the solution for replacing sed with perl in the above
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 10:23 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