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
Extracting from pipe delimited file. leepan2008 UNIX for Dummies Questions & Answers 1 02-17-2009 03:55 AM
Convert CSV file (with double quoted strings) to pipe delimited file lehmanbrothers Shell Programming and Scripting 11 02-13-2009 01:14 PM
How to generate a pipe ( | ) delimited file? anushree.a Shell Programming and Scripting 5 10-15-2008 03:35 AM
How to split pipe delimited file njgirl Shell Programming and Scripting 4 06-18-2008 06:15 PM
Grep for NULL in a pipe delimited file sureshg_sampat Shell Programming and Scripting 5 11-21-2006 06:15 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 05-26-2009
priyanka3006 priyanka3006 is offline
Registered User
  
 

Join Date: Apr 2009
Location: bangalore
Posts: 35
convert a pipe delimited file to a':" delimited file

i have a file whose data is like this::
osr_pe_assign|-120|wg000d@att.com|4|
osr_evt|-21|wg000d@att.com|4|
pe_avail|-21|wg000d@att.com|4|
osr_svt|-11|wg000d@att.com|4|
pe_mop|-13|wg000d@att.com|4|
instar_ready|-35|wg000d@att.com|4|
nsdnet_ready|-90|wg000d@att.com|4|
osr_nvt|-1|wg000d@att.com|4|
port_ip_assignment|-35|wg000d@att.com|4|



i want to convert this pipe delimited file to ":" delimited file in such a way that the there is no colon at the end of each row.

plzzzz help
urgent
  #2 (permalink)  
Old 05-26-2009
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,926

Code:
sed 's |$  ;s | : g' infile

  #3 (permalink)  
Old 05-26-2009
priyanka3006 priyanka3006 is offline
Registered User
  
 

Join Date: Apr 2009
Location: bangalore
Posts: 35
it is showing :s not found
  #4 (permalink)  
Old 05-26-2009
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,926
Could you post (copy/paste) the exact command and (error) messages from your terminal?
  #5 (permalink)  
Old 05-26-2009
priyanka3006 priyanka3006 is offline
Registered User
  
 

Join Date: Apr 2009
Location: bangalore
Posts: 35
its working thatnks a alot addict............
  #6 (permalink)  
Old 05-26-2009
durden_tyler's Avatar
durden_tyler durden_tyler is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2009
Posts: 552
Or if you have perl:


Code:
perl -ne '{s/\|$//; s/\|/~/g; print}' <file_name>

tyler_durden
  #7 (permalink)  
Old 05-26-2009
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,557
if you have Python

Code:
python -c "print '\n'.join([line.strip()[:-1].replace('|',':') for line in open('file')])"

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:32 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