How to check record delimiter of a file ?

My requirment is for every record of a particular file I've to check for a record delimeter (e.g. "\n") and if any row doesn't have "\n" then report it in error file .

Please suggest me to go through this.

Hello manab86,

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?
  • What output/errors do you get?
  • How do you know if you get a double row, e.g. is there a specific length or number of columns?
  • 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.

On top of what rbatte1 is asking, in your request, what's the difference between a "record" and a "row" (=line)?

Basically your file has a structure like this:

<record><delimiter><record><delimiter>.....

If some delimiter would be missing it would be:

<record><record><delimiter>.....

that is, two records without a delimiter between them. You can create a program to check for that BUT ONLY if you have a very rigid definition for what a "record" constitutes and provided that you can implement that definition in code.

In general you need to be able to find out where one record ends and the next begins. But with such a mechanism in place you do not need any delimiter (as a separate character) at all because the records are already "delimited" by their beginning/ending markers, whatever these may be.

I hope this helps.

bakunin

Also, is this to be done only with unix commands/utilities or can you write a program to do it? If so, what commands or utilities? Or what programming languages?