Delete last 2 fields from every record in a file

Sample file record :

"20130617003","2013-06-18T07:00:03","OUTWARD","01001011","TEST PLC","","HFX834346364364","20130617","10","DUM87534758","","1.28","826","020201","65879278","","","","","","010101","56789","DUMMY ","","","","","","","","5678901","","","11.28","826","","","01000009","01000021","false","true","0083","","","",""

  • want to delete the last 2 ,"","" from every record

any help obviously appreciated!

Please use only code tags for data and code samples.

To remove the 2 last fields you could do something like:

awk -F, 'NF=NF-2' OFS=, file
1 Like

Apologies in advance if I'm wrong about this - but I just had a quick look at your query, and from what I can see, you have published information that contains

  • Account numbers
  • Branch Sort Codes
  • A transaction amount.

If this is a work-related question, and you haven't anonymised the data, I would suggest you remove it pretty quickly, because you've almost certainly

  • committed a serious disciplinary offense for the organisation you work for, and,
  • broken the law

I wouldn't be particularly happy if I was the client, either.

Cheers,

thanks for noticing sideshowmark - but it wa all changed before submitting .... cheers :slight_smile: