Friday, March 09, 2012

Linux handling of sockets and open files

# kill all processes with open TCP sockets
kill -9 `lsof | grep ESTABLISHED | awk '{print $2}'`

# kill processes by port number of the TCP socket
fuser -k 22/tcp

Thursday, February 02, 2012

Teradata: Normalize BTEQ output

bteq <<EOF | 
awk 'BEGIN { 
   start=0; 
} 
{ 
   if (start==1) { 
      if (/^$/) { 
         exit; 
      } else { 
         print; 
      } 
   } 
   if (/^---/) { 
      start=1; 
   } 
}'
.logon host/user,password
select top 3 tablename
from dbc.tables
where databasename = 'myDB'
and tablekind='T'
order by 1
;
.logoff
.exit
EOF