my input file(.txt) has the information like
-------------------------------------
WS=123hi4
wd=WAST,RDP
------------------------------------
i need out like
----------------------------------
"where WS='123hi4' and wd in ('WAST','RDP')"
my input file(.txt) has the information like
-------------------------------------
WS=123hi4
wd=WAST,RDP
------------------------------------
i need out like
----------------------------------
"where WS='123hi4' and wd in ('WAST','RDP')"
one (hacky) way:
# sed "s/=\(.*\)/=\'\1\'/;s/,/\',\'/" infile | tr "\n=" " " | awk '{print "\"where "$1"="$2" and "$3" in ("$4")\"" }'
"where WS='123hi4' and wd in ('WAST','RDP')"
perl:
local $/;
my $str=<DATA>;
if($str=~/([^=]*)=([^=]*)\n([^=]*)=/){
print "where $1='$2' and $3 in(";
}
my $post=$';
my @tmp= $post=~/([^,]+)/g;
map {$_="'".$_."'"} @tmp;
print join ",", @tmp;
print ")";
__DATA__
WS=123hi4
wd=WAST,RDP