Delete last 2 fields from every record in a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Delete last 2 fields from every record in a file
# 1  
Old 06-25-2013
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","008 3","","","",""


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

any help obviously appreciated!

Last edited by bigbuk; 06-25-2013 at 10:49 AM..
# 2  
Old 06-25-2013
Please use only code tags for data and code samples.

To remove the 2 last fields you could do something like:
Code:
awk -F, 'NF=NF-2' OFS=, file

This User Gave Thanks to Franklin52 For This Post:
# 3  
Old 06-25-2013
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,
# 4  
Old 06-25-2013
changed!

thanks for noticing sideshowmark - but it wa all changed before submitting .... cheers Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Strip the first record off a file and isolate fields off of it

I have a 2 part question on how to this in unix scripting using kshell or c shell. I have a file described below: 1st record has 2 fields on it every other record has 22 fields on it. Example ABC, email address Detail 1 Detail 2 Detail 3 . . . 1st question is... (4 Replies)
Discussion started by: jclanc8
4 Replies

2. Shell Programming and Scripting

awk - compare 1st 15 fields of record with 20 fields

I'm trying to compare 2 files for differences in a selct number of fields. When differnces are found it will write the whole record of the second file including appending '|C' out to a delta file. Each record will have 20 fields, but only want to do comparison of 1st 15 fields. The 1st field of... (7 Replies)
Discussion started by: sljnk
7 Replies

3. UNIX for Dummies Questions & Answers

Delete a record in a xml file using shell scripting

find pattern, delete line with pattern and 3 lines above and 8 lines below the pattern. The pattern is "isup". The entire record with starting tag <record> and ending tag </record> containing the pattern is to be deleted and the rest to be retained. <record> ... (4 Replies)
Discussion started by: sdesstp
4 Replies

4. Shell Programming and Scripting

delete text from each record in a file

Hi guys, I have been given a small task to do and I am stuck already. I have to format a file with people's emails address in it ready for pasting into the BCC section of an email. The file looks like this:- bob@ibm.com SMTP BOB SMITH text text text sue@icl.org SMTP Susy Smith text text... (8 Replies)
Discussion started by: joe_evans
8 Replies

5. Shell Programming and Scripting

Need unix commands to delete records from one file if the same record present in another file...

Need unix commands to delete records from one file if the same record present in another file... just like join ... if the record present in both files.. delete from first file or delete the particular record and write the unmatched records to new file.. tried with grep and while... (6 Replies)
Discussion started by: msathees
6 Replies

6. Shell Programming and Scripting

How to delete 1 record in large file!

Hi All, I'm a newbie here, I'm just wondering on how to delete a single record in a large file in unix. ex. file1.txt is 1000 records nikki1 nikki2 nikki3 what i want to do is delete the nikki2 record in file1.txt. is it possible? Please advise, Thanks, (3 Replies)
Discussion started by: nikki1200
3 Replies

7. UNIX for Dummies Questions & Answers

Perl Script to delete record if it exceeds 199 fields

HI All, I am new to perl ,need your inputs for my better understanding. I have 5 UNIX files ,inside which only required fields will be loaded except with junk data mentioned in double quotes .For Ex File has below information: Process=High Name=Albert Age=27 ... (8 Replies)
Discussion started by: Perlbaby
8 Replies

8. Shell Programming and Scripting

How to delete first record from all the file?

hi All, need help...!! I want to delete header record from all the files in current directory. using sed command i can delete first record from a file but i want to delete first record from all the files so can anybosy help me how can i do this? I will appreciate your help. (3 Replies)
Discussion started by: NirajThakar
3 Replies

9. UNIX for Dummies Questions & Answers

Delete a single record from a file

Hello all, Is there a function for deleting a single record from a file? Thanks in advance... (4 Replies)
Discussion started by: klafte
4 Replies

10. UNIX for Dummies Questions & Answers

How to delete a record from a csv file

Hi Guys I have downloaded a table from oracle database in .csv format. it has many fields as Title, First Name, Last Name etc. I have to download distinct titles from database and now i have to check all those titles from data of First Name one by one. and then i have to delete matched record.... (1 Reply)
Discussion started by: Rajeev Agrawal
1 Replies
Login or Register to Ask a Question