If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > remove line feeds - awk/sed/tr problem?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-07-05, 11:42
apringle apringle is offline
Registered User
 
Join Date: Mar 2005
Posts: 1
Question remove line feeds - awk/sed/tr problem?

Hi,

I have a file of the format:

start: 1001
12
32
34
35
36

start: 1002
asd
we
23

I want to format this output to read:
start: 1001, 12, 32, 34, 35, 36
start: 1002, asd, we, 23

..so in other words remove line feeds and use the keywords start,a dn a blank line to delimit the start and end of a record (as you can see these records are of variable length. So I know I can remove line feeds with things like tr (tr -d '\n' < file.txt), but can't work out how I can get this to work with record delimiters. I tried stuff in awk and sed but can't work this one out - any ideas?
Reply With Quote
  #2 (permalink)  
Old 03-07-05, 13:18
vgersh99 vgersh99 is offline
Registered User
 
Join Date: Apr 2004
Location: Boston, MA
Posts: 325
nawk 'BEGIN{RS=FS="";OFS=","} $1=$1' file
__________________
vlad
+-----------------------+
| #include <disclaimer.h> |
+-----------------------+
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On