The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 01-06-2009
jaduks's Avatar
jaduks jaduks is offline
Registered User
  
 

Join Date: Aug 2007
Location: Assam,India
Posts: 167

Code:
$ cat tri.txt
aaa|1234||2bc||rahul|tamilnadu
bba|2234||b4c||bajaj|tamilnadu

$ awk 'BEGIN{OFS=FS="|"}{ for(k=0;k<=NF;k++)
if ( $k == "" )
$k="NULL"
print $0}' tri.txt

aaa|1234|NULL|2bc|NULL|rahul|tamilnadu
bba|2234|NULL|b4c|NULL|bajaj|tamilnadu