在我的档案中,我有以下内容。
<sql type="cognos">SELECT * FROM [PG WIND JAROS - JAROSODS].AGREMENT_MAS WHERE FILTER = 'Saravana' and ADDress = '32/36 Abc Nagar CH' </sql>
<sql type="cognos">select OBJECT_TYPE 'Object Type',
OBJECT_NAME "Object Name",
from [PG WIND Jaros - JAROSDM].CX_WIND_LOOKUP_REF WHERE Filter = 'Kumaar' and STATUS = 'RICH' </sql>
这里我必须将所有内容转换为小写,但单引号中的字符串除外。即,
输出:
<sql type="cognos">select * from [pg wind jaros - jarosods].agrement_mas where filter = 'Saravana' and address = '32/36 Abc Nagar CH' </sql>
<sql type="cognos">select object_type 'Object Type',
object_name "object name",
from [pg wind jaros - jarosdm].cx_wind_lookup_ref where filter = 'Kumaar' and status = 'RICH' </sql>
我怎样才能在SED中实现这一目标?请帮帮我......
答案 0 :(得分:1)
这是一个awk
解决方案:
awk -F\' '{for (i=1;i<=NF;i++) printf "%s"(NF==i?RS:FS),(i%2?tolower($i):$i)}' file
<sql type="cognos">select * from [pg wind jaros - jarosods].agrement_mas where filter = 'Saravana' and address = '32/36 Abc Nagar CH' </sql>
<sql type="cognos">select object_type 'Object Type',
object_name "object name",
from [pg wind jaros - jarosdm].cx_wind_lookup_ref where filter = 'Kumaar' and status = 'RICH' </sql>
答案 1 :(得分:0)
以下是sed
解决方案:
sed -e "s/^\([^']*\)$/\L\1/" -e "s/\([^']*\)\('[^']*'\)/\L\1\E\2/g" -e "s/\('[^']*\)$/\L\1/" file
\L
将替换为小写(直到找到\E
)。