I have few files from windows which are tab delimited or �|' delimited files.
I need to convert these files without any delimiter ( so in a way it would become variable length with no delimiter )
Can someone help me with the command in bourne shell scripts., ( I am trying with awk )
Thanks In Advance,
How do your code looks like?
Regards
Honestly , so far
I had been trying with command line Vi , Sed commands.
trying to put the code together now , I had from the forum , so looking for <tr> and <expand> too
To remove the pipe symbols:
tr -d '|' < FILE
To replace the pipe symbols with spaces:
tr '|' ' ' < FILE
To remove the tabs:
tr -d '\t' < FILE
To replace the tabs with spaces:
tr '\t' ' ' < FILE
Thanks for the Tips,
For a normal Situation , for e-g
Normal Data file
Field1<tab>Field2<tab>Field3 ,
Field1<tab>Field2<tab>Field3 ,
All the tabs will be removed and become a variable length data , after using tr -d '\t' < FILE
Field1Field2Field3 ,
Field1Field2Field3 ,
For a comma separated data file , the possibility of the comma appearing in the actual field value is higher for e-g
Field1,Field2,Field3
Field1,ABC,corporation,Field3
We can�t use <tr> to remove all the comma , Is there a way to distinguish the fields delimiters and the field value.
Please advice.
It could be possible only if there are some fixed conditions.
For eg. take your data.
Field1,Field2,Field3
Field1,ABC,corporation,Field3
- If you think Filed1 and field3 will never have cammas in them, then logically you need to remove the first and the last commas (or say last 5 commas). And this can be done.
Field1,ABC,corporation,Field3,Field4,Field5,Field6,Field7
- Or you can avoid those that come with in quotes (double " or single ' or some other character).
Like
Field1,"ABC,corporation",Field3
Without any condition, how will you yourself decide which should not/be removed?
Sure , I agree. Let me check all the possible option.
Thanks for the reply.