Advertisement
MertcanGokgoz

awk roaster

Dec 20th, 2018
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.62 KB | None | 0 0
  1. awk 'BEGIN {count = 1
  2.    print  "INSERT INTO ofRoster(ROSTERID, USERNAME, JID, SUB, ASK, RECV, NICK) VALUES (\47 1\47, \47test\47,\47test@test.com\47,\47 3\47,\47 -1\47, \47-1\47, \47 "
  3. }
  4. {  
  5.    if($0 ~ /@/ ) {
  6.    count = count + 1
  7. print"\47), (\47",count,"\47, \47",substr(FILENAME,1,length(FILENAME)-4),  "\47,\47 ",  substr($1, 3, length($1)-4), "\47,\47 3\47,\47 -1\47, \47-1\47, \47"
  8. }
  9.    if($0 ~ /name/) {
  10.    if(NF==4)
  11.    print  substr($3,2, length($3)), substr($4, 1, length($4)-2)
  12.    else if(NF==5)
  13.    print  substr($3,2, length($3)), $4, substr($5, 1, length($5)-2)    
  14. }
  15. }
  16. END {print "\47);"} '
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement