ksh scripting help needed.

I am trying to create a script to manipulate numerous file and at first I thought it would be a simple task but at this point i am ready to break my computer! I am new to unix scripting so hopefully someone out there thinks this is super easy and can help me out!

A sample of the problem file is as follows. I am trying to remove certain line feeds:

*line1a<cr><lf>
line1b<cr><lf>
line1c<cr><lf>
*line2a<cr><lf>
line2b<cr><lf>
line2c<cr><lf>

what I need is:
*line1a<cr>
line1b<cr>
line1c<cr><lf>
*line2a<cr>
line2b<cr>
line2c<cr><lf>

  • there is a unique string to identfy the beginning of each line.

In theory I was using the tr command to remove all line feeds and then was planning on using sed to add the line feeds back in where they were needed but since there was no line feed at all in the file sed command does not work.

any and all tips/help is greatly appreciated!

Post code you've already done its gonna be easier to help

What is the criterion for printing a linefeed?

Given your file and desired output above, this does the trick:

awk '
  NR > 1 && NR % 3 == 1 { print "" } ## adjust to taste
  { printf "%s", $0 }
  END { print ""}
' "$FILE"

If you want something different, change the condition in the script.