gpt4 book ai didi

linux - 如何在 Ubuntu 中撤消 "mv file -"命令

转载 作者:太空宇宙 更新时间:2023-11-04 05:38:26 25 4
gpt4 key购买 nike

据您所知,-与 Linux 中的不同命令结合使用有不同的用途。例如in combination with cd command ,这意味着“将目录更改为先前的位置”和 in combination mv or cat command这意味着stdinstdout .

不幸的是,我错误地将这个字符与mv一起使用命令。我想将文件移至更改目录之前所在的位置,但我将其移至 stdin相反。

有什么办法可以恢复我的文件吗?

我运行这个命令:

# mv myfile -

最佳答案

I moved it to stdin instead.

不,您移动到了一个按破折号字面命名的文件(您将使用 /dev/stdin/proc/self/fd/0 来引用 stdin ,即 file descriptor 0)。

你想要

mv -i ./- myfile

这是通常的做法(在奇怪的路径前添加 ./ 前缀)。 -i 以交互方式请求确认。

有时,输入奇怪文件的路径(例如包含单个换行符的文件名)甚至都不容易。您可以使用 globbing (阅读 shell expansion ),例如mv -i ./?文件

参见mv(1)path_resolution(7)glob(7)proc(5)

好习惯是避免文件路径中出现奇怪的字符。

关于linux - 如何在 Ubuntu 中撤消 "mv file -"命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46572373/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com