Home
Categories
WIKI
Topic
User
LANGUAGE:
中文
English
deepin script使用判断符号[]提示unexcepted operator怎么办?
Experiences and Insight
340
views ·
0
replies ·
To
floor
Go
AlwaysQuiet
deepin
2020-03-03 17:12
Author
代码如下:
#!/bin/bash
read -p "Do you want to save the file[y/n]? " choice
[ $choice == ‘y’ -o $choice == ‘Y’ ] && echo “you save the file.” && exit 0
[ $choice == ‘n’ -o $choice == ‘N’ ] && echo “you don’t save the file.” && exit 0
运行时提示,
[]里内容两侧也留了空白,不知道该怎么改了。
然后之前还碰到个问题,就是我输入echo -e "xxx\n",Linux里-e是激活转义符号的,但是deepin里会直接输出 -e xxx。
感觉比较奇怪吧,难道debian也是这样的吗?如果说echo -e里去掉-e没什么问题,但是[]不能用的话相关的脚本就没办法写了,网上也没找到相关资料,还请大佬指导一下,感激不尽!
Reply
Like 0
Favorite
View the author
All Replies
No replies yet
Please
sign
in first
Featured Collection
Change
[Tutorial] deepin25 WSL Offline Installation Guide
UOS AI 2.8 Released! Three New Intelligent Agents & Major Evolution
Solid Q&A | deepin 25 Common Questions – The Immutable System Edition
New Thread
Popular Ranking
Change
WiFi Drivers
Popular Events
More
#!/bin/bash
read -p "Do you want to save the file[y/n]? " choice
[ $choice == ‘y’ -o $choice == ‘Y’ ] && echo “you save the file.” && exit 0
[ $choice == ‘n’ -o $choice == ‘N’ ] && echo “you don’t save the file.” && exit 0
运行时提示,
[]里内容两侧也留了空白,不知道该怎么改了。
然后之前还碰到个问题,就是我输入echo -e "xxx\n",Linux里-e是激活转义符号的,但是deepin里会直接输出 -e xxx。
感觉比较奇怪吧,难道debian也是这样的吗?如果说echo -e里去掉-e没什么问题,但是[]不能用的话相关的脚本就没办法写了,网上也没找到相关资料,还请大佬指导一下,感激不尽!