![](/img/trans.png)
[英]remove double dots from a string and not the single dot using shell script
[英]Remove single quotes from string in shell script
這是我的shell腳本 -
if ! options=$(getopt -o : -l along:,blong:,clong: -- "$@")
then
# something went wrong, getopt will put out an error message for us
exit 1
fi
set -- $options
while [ $# -gt 0 ]
do
case $1 in
--along) echo "--along selected :: $2" ;;
--blong) echo "--blong selected :: $2" ;;
--clong) echo "--clong selected :: $2" ;;
esac
shift
done
當我運行腳本時,我得到以下輸出 -
./test.sh --along hi --blong hello --clong bye
--along selected :: 'hi'
--blong selected :: 'hello'
--clong selected :: 'bye'
問題是我不想用單引號顯示參數('hi','hello','bye')。 我應該怎么做才能擺脫這些報價?
對getopt使用選項-u
或--unquoted
,即
if ! options=$(getopt -u -o : -l along:,blong:,clong: -- "$@")
getopt的聯機幫助頁說為-u
:
不要引用輸出。 請注意,空格和特殊(依賴於shell)字符可能會在此模式下造成嚴重破壞(就像它們與其他getopt(1)實現一樣)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.