mv命令末尾的星号是做什么的 [英] What does an asterisk at the end of a mv command do
问题描述
所以我要移动一堆文件
mv /source /dest &
mv /source/* /dest/dest/ &
...
...
然后我变得粗心
mv /source/filena* /dest/dest/ *
天哪! ^ c ^ c ^ c ^ c
[终端命令无响应]到底是怎么回事?
OMG! ^c^c^c^c
[No Response from terminal command]
What is actually going on here?
当我在命令末尾放置 *
(星号)而不是&
(&"号)时会发生什么?
What happens when I put an *
(asterisk) at the end of a command instead of an &
(ampersand)?
推荐答案
shell扩展了通配符 *
. mv
命令从不会看到通配符,只能看到扩展的结果.
The shell expands the wildcard *
. The mv
command never sees the wildcard, only the result of the expansion.
通配符 *
按字典顺序扩展到当前目录中的文件列表.如果最后一个文件是目录,则所有前面的文件(/source.filenafoo
,/source/filenabar
,/dest/dest
, hello
)将移至该子目录.如果最后一个文件不是目录,mv
会抱怨目标 a.png
不是目录"(或类似的话).
The wildcard *
expands to the list of files in the current directory in lexicographic order. If the last file is a directory, then all the preceding files (/source.filenafoo
, /source/filenabar
, /dest/dest
, hello
) are moved to that subdirectory. If the last file is not a directory, mv
complains that "target a.png
is not a directory" (or words to that effect).
请参阅 mv是什么./*
不指定目的地吗?以获得更详细的示例.
See What does mv ./*
without specifying destination do? for more detailed examples.
这篇关于mv命令末尾的星号是做什么的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!