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
editing ELF file tejuwala Linux 1 05-18-2008 12:22 AM
Editing file rahul303 Shell Programming and Scripting 4 09-23-2007 11:49 PM
Editing the File using Awk awk_beginner Shell Programming and Scripting 3 04-06-2007 11:43 AM
Help with editing file dsravan Shell Programming and Scripting 4 01-31-2007 01:59 PM
File editing using awk rinku11 Shell Programming and Scripting 2 11-23-2006 11:34 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-16-2007
Mohammed Mohammed is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 12
Editing File using awk/sed

Hello Awk Gurus,

Can anyone of you help me with the below problem. I have got a file having data in below format

pmFaultyTransportBlocks
-----------------------
9842993


pmFrmNoOfDiscRachFrames
-----------------------
NULL


pmNoRecRandomAccSuccess
-----------------------
30646380

I want to format this file into below format so that I can export it to excel using .csv

pmFaultyTransportBlocks,9842993
pmFrmNoOfDiscRachFrames,NULL
pmNoRecRandomAccSuccess,30646380

Thanks in Advance,
Mohammed
  #2 (permalink)  
Old 05-16-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,957
Code:
awk '{ if( $0 !~ "^-" && length($0) ) { if ( set == 0 ) { printf "%s", $0; set = 1 } else { set = 0; printf ",%s\n", $0 } } }' filename
  #3 (permalink)  
Old 05-16-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Code:
sed -n "/^ *$/!{N;/\n---*$/s//,/;N;s/\n//p;}" file
  #4 (permalink)  
Old 05-16-2007
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
Code:
nawk 'BEGIN{FS=RS="";OFS=","}{print $1,$3}' myFile
  #5 (permalink)  
Old 05-16-2007
Mohammed Mohammed is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 12
Thanks vgersh99 your code is working really fine.
Thanks others for also helping me out
Thanks again!
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 04:06 PM.


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