Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2005
    Posts
    1

    Question Unanswered: 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?

  2. #2
    Join Date
    Apr 2004
    Location
    Boston, MA
    Posts
    325
    nawk 'BEGIN{RS=FS="";OFS=","} $1=$1' file
    vlad
    +-----------------------+
    | #include <disclaimer.h> |
    +-----------------------+

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •