代码区项目交易流程

The sed command does not work correctly in Solaris but works in linux


I have following string which is used further in sed command. Its working properly in linux but NOT working in Solaris

-bash-3.00$ string="CREATESETTABLEDATABASE1.TABLE1(uid)CREATESETTABLEDATABASE1.TABLENAMEuid,cid,mid)DATABASE2.TABLENAME(hi,hello)"

In Linuxbox, it outputs properly as below.

echo $string | sed -e 's/.*CREATESETTABLE[^)]\+TABLENAME\(.*\)/\1/g' uid,cid,mid)DATABASE2.TABLENAME(hi,hello)

I solaris, sed search is not working returns full string irrespective of search string match.

echo $string | sed -e 's/.*CREATESETTABLE[^)]\+TABLENAME\(.*\)/\1/g' CREATESETTABLEDATABASE1.TABLE1(uid)CREATESETTABLEDATABASE1.TABLENAMEuid,cid,mid)DATABASE2.TABLENAME(hi,hello)

I want the same output to be printed in solaris.

I believe \+ doesn't work on older sed even on BSD it is not supported. Try this sed:

sed -e 's/.*CREATESETTABLE[^)]*TABLENAME\(.*\)/\1/g'

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

点击收藏

LAST Moving home - updates to vcsh usage Lightning Fast Terminal File Manager NEXT