[problem help] 终端运行echo命令
Tofloor
poster avatar
#@¥
deepin
2024-08-01 14:59
Author

image.png

这是否是bug😳

Reply Favorite View the author
All Replies
gfdgd_xi
deepin
Ecological co-builder
2024-08-01 15:09
#1

可以试一下前面加个

set +H

或者外面换成单引号

image.png

Reply View the author
Indedeve
deepin
Backbone of ecological co-construction group
2024-08-01 15:18
#2

你的 > 前面加空格了吗?

Reply View the author
昨夜的星辰
deepin
2024-08-01 15:57
#3

在 > 的前后都要加空格

image.png

Reply View the author
兰蔻
deepin
2024-08-01 16:16
#4
Indedeve

你的 > 前面加空格了吗?

重定向操作符 > 在bash中是元字符,可以分隔单词,不需要加空格。看报错信息,明显是双引号内的历史替换出了问题。字符 ! 引入了历史替换(就像 $ 引入变量和参数扩展、算术扩展、命令替换一样),并且可以在双引号引用机制中生效。

解决办法可以像一楼那样,关闭历史扩展功能(使用命令 set +H 来关闭);或者让 ! 后面跟着一个空格:

echo "print('hello world! ')">~/Downloads/hello.py
Reply View the author
神末shenmo
deepin
Spark-App
2024-08-01 17:17
#5
兰蔻

重定向操作符 > 在bash中是元字符,可以分隔单词,不需要加空格。看报错信息,明显是双引号内的历史替换出了问题。字符 ! 引入了历史替换(就像 $ 引入变量和参数扩展、算术扩展、命令替换一样),并且可以在双引号引用机制中生效。

解决办法可以像一楼那样,关闭历史扩展功能(使用命令 set +H 来关闭);或者让 ! 后面跟着一个空格:

echo "print('hello world! ')">~/Downloads/hello.py

这个历史扩展怎么用呢

Reply View the author
鲜衣怒马
deepin
2024-08-01 20:53
#6
神末shenmo

这个历史扩展怎么用呢

!+历史命令编号

image.png

Reply View the author
#@¥
deepin
2024-08-02 08:46
#7
gfdgd_xi

可以试一下前面加个

set +H

或者外面换成单引号

image.png

成功了,谢谢👍

Reply View the author
#@¥
deepin
2024-08-02 08:46
#8

谢谢大家帮忙解惑thanks 用set +H解决了

Reply View the author