简体   繁体   English

Linux中的./!$是什么意思?

[英]What does ./!$ mean in Linux?

A noobie Linux learner here. 这里有一个noobie Linux学习者。

I created a python script and chmod 700 filename.py , when I was going to using ./filename.py , my instructor came and use ./!$ to run the file. 我创建了一个python脚本和chmod 700 filename.py ,当我打算使用./filename.py ,我的讲师来了并使用./!$来运行该文件。

What does the ./!$ that actually mean? 实际意味着./!$是什么意思? I couldn't google it out. 我无法谷歌。 I'd greatly appreciate for a link of cheatsheet for the similar commend too. 我也非常感谢cheatsheet的类似推荐链接。

Thanks in advance. 提前致谢。

Suppose I just ran a command python test.py . 假设我刚刚运行了命令python test.py This was my last command I entered into the shell. 这是我进入shell的最后一个命令。 However, its argument was test.py . 但是,它的论点是test.py

Remembering that ./ refers to the current working directory, when I type ./!$ I get the following output: 记住./是指当前工作目录,当我输入./!$我得到以下输出:

$ ./!$
./test.py
./test.py: line 1: import: command not found
./test.py: line 2: $'\r': command not found
./test.py: line 3: syntax error near unexpected token `('
'/test.py: line 3: `df = pd.DataFrame([

By context clues my last argument was used as the !$ . 通过上下文线索,我的最后一个参数被用作!$

If I enter several arguments such as python test.py test2.py I get: 如果我输入几个参数,如python test.py test2.py我得到:

$ ./!$
./test2.py
./test2.py: line 1: import: command not found
Unable to initialize device PRN

Confirming my intuition. 确认我的直觉。

Fully agree with Michael Berkowski 's comment. 完全同意Michael Berkowski的评论。 !$ refers to the last argument from the previous bash command. !$指的是上一个bash命令的最后一个参数。 For instance, if you type echo hello world then !$ would expand to "world". 例如,如果你键入echo hello world那么!$将扩展为“world”。

In your case, the !$ is expanded into "filename.py". 在您的情况下, !$扩展为“filename.py”。 The command becomes strictly the same as above: ./filename.py . 该命令与上面的命令完全相同: ./filename.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM