Convert a fixed width file to a delimited file

Hi - this is a generic question .... is there any utility which can convert a fixed width file format to a delimited file (any given character delimited) ?

Hi. try this

tr -s '\n' ' ' <file.txt

I think I understood
Maybe so with a separator for example a dot

echo $(<file.txt) | sed 's/\.\+/&\n/g'

Hello i4ismail,

I have a few to questions pose in response first:-

  • Is this homework/assignment? There are specific forums for these.
  • What have you tried so far?
  • Do you have some sample input data to work with?
  • What output/errors do you get?
  • What OS and version are you using?
  • What are your preferred tools? (C, shell, perl, awk, etc.)
  • What logical process have you considered? (to help steer us to follow what you are trying to achieve)

Most importantly, What have you tried so far?

There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.

We're all here to learn and getting the relevant information will help us all.

Thanks, in advance,
Robin

The phrase is important!
"""any given character delimited"""
I read this as ANY character of ASCII, UNICODE or binary!

An assumption that the delimiter is any printable ASCII character was not even in my thoughts.
So until the OP clarifies what "any given character delimited" is then we have to assume the "0x00" and "0x80 to 0xFF" characters might be wanted, removed or replaced.

Last login: Tue Jul 23 11:22:27 on ttys000
AMIGA:amiga~> text="A delimited"$'\x80'"text file."$'\x80'
AMIGA:amiga~> byte=$'\x80'
AMIGA:amiga~> sed 's/\'"${byte}"'\+/&\n/g' <<< "${text}"
sed: 1: "s/\?\+/&\n/g": RE error: illegal byte sequence
AMIGA:amiga~> tr -s ${byte} ' ' <<< "${text}"
tr: Illegal byte sequence
AMIGA:amiga~> _

if you have access to gawk , check man gawk and search for FIELDWIDTHS .
if not, you can simulate FIELDWIDTHS yourself.