Sed:-E expression #1, char 103:unknown option to ' s '

Source: Internet
Author: User

The server configuration file is modified with a shell script to delete the contents after the string "(C)" in the following three lines of string.

Ums.newcopyright.zh_cn= (C) 1998-2015öððëíšñ¶¹é Ýóðïþ¹«ëÿ°æèšëùóð
ums.newcopyright.en_us= (C) 1998-2015 ztd Corporation. All rights reserved
ums.newcopyright.ru_ru= (C) 1998-2015§¬§à§â§á§à§â§ñ§è§ú§ñztd.§£§ã§ö§á§â§ñ§ó§ñ§ù§ñ§ë§ú§ë§ö§ ߧí

Consider replacing the implementation with SED:

#gedit ums-server/works/global/deploy/deploy-usf.properties
deploy_usf_file=./ums-server/works/global/ Deploy/deploy-usf.properties
newcpcn= ' ums.newcopyright.zh_cn= (c) '
newcpus= ' ums.newcopyright.en_us= (c) '
newcpru= ' ums.newcopyright.ru_ru= (C) '
newcpcn_line= ' grep $newcpcn $deploy _usf_file '
newcpus_line= ' grep $newcpus $deploy _usf_file '
newcpru_line= ' grep $newcpru $deploy _usf_file '
if [-N ' $newcpcn _line "-a-n" $ Newcpus_line "-a-n" $newcpru _line "];then
    sed-i" S#${NEWCPCN_LINE}#${NEWCPCN} #g "$deploy _usf_file sed-i
    " s#$ {Newcpus_line}#${newcpus} #g ' $deploy _usf_file
    sed-i ' S#${newcpru_line}#${newcpru} #g ' $deploy _usf_file
    If ["$?"-eq 0]; Then
        echo "[] set Newcopyright statement in $deploy _usf_file OK."
    Fi
Else
    echo "[Ten] Error:set newcopyright statement in $deploy _usf_file fail."
Fi

Avoid replacing the text with a separator character/, using # as the separator. To run a script that prompts for an error:

Sed:-E expression #1, char 103:unknown option to ' s '

Check the script found that similar three-line replacement operation, the first two lines no problem, the error in the third line, replace the failure. Suspect that the string to be replaced contains a delimiter # (the following analysis may not be the reason ...). )

NEWCPCN and so on three variables are used in the definition of single quotes, the string is closed all meta, should be not wrong.

The question should still be that the string in the third row is more complex, and there is a problem with the string variable, which is not clear. Learn the shell 13 and ask. Σ (° °| | |) ︴

Change the way of thinking to solve.

It is understood that the whole line of Newcpru-headed string is replaced with Newcpru, and the entire line is replaced with the SED whole line substitution parameter C:

#gedit ums-server/works/global/deploy/deploy-usf.properties
deploy_usf_file=./ums-server/works/global/ Deploy/deploy-usf.properties
newcpcn= ' ums.newcopyright.zh_cn= (c) '
newcpus= ' ums.newcopyright.en_us= (c) '
newcpru= ' ums.newcopyright.ru_ru= (C) '
newcpcn_line= ' grep $newcpcn $deploy _usf_file '
newcpus_line= ' grep $newcpus $deploy _usf_file '
newcpru_line= ' grep $newcpru $deploy _usf_file '
if [-N ' $newcpcn _line "-a-n" $ Newcpus_line "-a-n" $newcpru _line "];then
    sed-i"/^ $newcpcn/c$newcpcn "$deploy _usf_file sed-i
    "/^ $newcpus/c$ Newcpus "$deploy _usf_file
    sed-i"/^ $newcpru/c$newcpru "$deploy _usf_file
    If [" $ "-eq 0]; then
        echo" [10 ] Set Newcopyright statement in $deploy _usf_file OK. "
    Fi
Else
    echo "[Ten] Error:set newcopyright statement in $deploy _usf_file fail."
Fi


Analysis to be continued, welcome to the talent!!











Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.