bash-3.2$ awk '$1~/^SERV/{printf "%s\n",$1} $1~/,/{printf "%s\n",gensub(/,/,"",1,$1);next} {gsub(/,$/,"")}{if($1 !~ /[A-Z]/ && length($1)<8){printf "%s\n",$1}} $2~/,/{printf "%s\n",gensub(/,/,"\n","g",$2)}' test.log
SERVER001 awk: calling undefined function gensub input record number 1, file test.log source line number 1 |
Can you use GNU awk, or nawk instead? Your OSes awk must be a museum piece.
|
Please use [code][/code] tags so we can ascertain if you are entering data correctly.
Also you say this for a server ... would it happen to be Solaris?I have had issues from other users on this platform as awk seems to be quite dated. Maybe provide: Code:
awk --version Code:
awk 'BEGIN{RS="[ ,\n]+"}!/^2011/' file |
Patterns in awk can include newline and therefore handle input which continues across multiple lines.
|
I might be missing the point, but it seems like a one-liner won't do the trick since INSERT only takes one row at a time. I would therefore do something like this:
Code:
#!/bin/bash Kevin Barry |
Quote:
Exactly ... which is (in less words) what I said in #7. Cheers, Tink |
All times are GMT -5. The time now is 02:12 PM. |