fill a NIL into the blank field

Hello,

I have a record which split with "," I would like to check..if the field is empty and it will field "NIL" into the field.

input

45111,40404,peter,,0303403,0,030304,john,,9,0,

output

45111,40404,peter,NIL,0303403,0,030304,john,NIL,9,0,

One of the many ways...

echo "45111,40404,peter,,0303403,0,030304,john,,9,0," | sed -e "s/,,/,NIL,/g"

Plz try this..

or

but you echo one record.....ONLY
I have a file which over 100,000 record and I would to fill all records like this format...any idea

sed -e "s/,,/,NIL,/g" file > tmp
mv tmp file

Great! work fine

also, how can i check the specify field (such as field no#11 and the value is "0", than change to "0:00")?

Give a try on thsi..

Output:
45111,40404,peter,NIL,0303403,0,030304,john,NIL,9,0:00,

yes...it work!! :slight_smile: