Replace 3 fields with null in the file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Replace 3 fields with null in the file
# 1  
Old 09-12-2007
Replace 3 fields with null in the file

Hi,
I have a file with 104 columns delimited by comma.

I have to replace fields 4,5 and 19 with null values and after replacing the columns in the file , the file should be still comma delimited. I am new to shell scripting, Experts please help me out.

Thank you
# 2  
Old 09-12-2007
i think i got it

awk 'BEGIN{OFS=FS=","}{$4=$5=$19=""}{print}' input.csv > output.csv
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Fields shifting in file, do to null values?

The below code runs and creates an output file with three sections. The first 2 sections are ok, but the third section doesn't seem to put a . in all the fields that are blank. I don't know if this is what causes the last two fields in the current output to shift to a newline, but I can not seem... (3 Replies)
Discussion started by: cmccabe
3 Replies

2. Shell Programming and Scripting

Replace Null with 0 in 6th column in file

Hi Forum. I tried to search for the solution online but I couldn't find specifically what I'm trying to achieve. I want to replace Null with 0 in column position#6; Any other values would be retained. Before: 52653363|3407732947|28-MAR-2014... (3 Replies)
Discussion started by: pchang
3 Replies

3. Shell Programming and Scripting

Replace a field where values are null in a file.

Hi, I've a pipe delimited file and wanted to replace the 3rd field to 099990 where the values are null. How can I achieve it using awk or sed. 20130516|00000061|02210|111554|03710|2|205069|SM APPL $80-100 RTL|S 20130516|00000061|02210|111554|03710|2|205069|SM APPL $80-100 RTL|S... (12 Replies)
Discussion started by: rudoraj
12 Replies

4. Shell Programming and Scripting

Aligning output with null fields in shell script

Hello Gurus ! I have what probably amounts to a few simply changes to fix; however for the life of me I cannot seem to get it ti work. I need to align the output of my script (I am writing to a logfile)... here's the lines in my code: if then echo "NODE: $node" >> $logfile... (6 Replies)
Discussion started by: gvolpini
6 Replies

5. Shell Programming and Scripting

Replace 0's with NULL

Hi all, Need a small help I am in lookout for a command that changes 0's to NULL in my file, The content will look like 1139,223108,R,2009,0,854,854,854,732,854,854,854,854,854 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,... (3 Replies)
Discussion started by: Sri3001
3 Replies

6. Shell Programming and Scripting

replace some string by null??

I have a string like In this string I want to delete both "." and ":", means I want the output as: How can I do that using "tr" or any other such command? (6 Replies)
Discussion started by: ash.g
6 Replies

7. Shell Programming and Scripting

Find out if few fields in a file are null

Hi, I've a pipe delimited file where I want to find out a number of lines where 1st 2nd and last field are null using awk/sed. Is it possible? Thanks (5 Replies)
Discussion started by: rudoraj
5 Replies

8. Shell Programming and Scripting

Cannot replace null with space

I have a fixed width text file which has some null characters in no particular order. I need to replace them with spaces so that the width remains same. I tried this: tr "\000" "\040" < mainfile > newfile Does not work. I tested that it works the other way round: $ echo "hello" |tr... (1 Reply)
Discussion started by: rikxik
1 Replies

9. Shell Programming and Scripting

exclude records with null fields

Hi, can I do something like this to add a condition of checking if the 4th field is number or space or blank also: awk -F, '$4 /^*||*/' MYFILE >> OTHERFILE I also want the other part i.e. I need to exclude all lines whose 4th field is space or blank or number: MYFILE a,b,c,d,e a,b,c,2,r... (2 Replies)
Discussion started by: praveenK_Dudala
2 Replies

10. Shell Programming and Scripting

Find null fields in file

Hi All, I have some csv files out of which i want to find records which have empty values in either the 14th or 16th fields. The following is a sample. $cut -d',' -f14,16 SPS* | head -5 VOIP_ORIG_INFO,VOIP_DEST_INFO sip:445600709315@sip.com,sip:999@sip.com... (2 Replies)
Discussion started by: rahulrathod
2 Replies
Login or Register to Ask a Question