有谁知道如何替换()之间的特定单词.因此,例如,在两组括号中替换单词和之间或之间:
(grade=’C’ and grade=’D’ and grade=’E’) and (int_rate>=10 and int_rate<=20) and pub_rec>=0
and term=’ 36 months’
这将是:
(grade=’C’ or grade=’D’ or grade=’E’) and (int_rate>=10 or int_rate<=20) and pub_rec>=0
and term=’ 36 months’
真是愚蠢的做法:
$sed 's/and/or/g' INPUT | sed 's/) or (/) and (/' | sed 's/\(.*\)or/\1and/' (grade='C' or grade='D' or grade='E') and (int_rate>=10 or int_rate<=20) and pub_rec>=0 and term=' 36 months'