我尝试通过 wget 从 civitai.com 下载模型文件,并得到文件名“201259?type=Model”。 wgethttps://civitai.com/api/download/models/201259?type=Model&format=SafeTensor&size=pruned&fp=fp16
当我尝试“ls -al”时,出现 ls: 无法访问“201259?type=Model”: 没有此文件或目录 ,文件属性“-????????? ? ? ? ? ?”我该如何删除它?
答案1
使用ls
来处理奇怪的文件名并不是最理想的。阅读man 1 stat
,并执行:
stat -c "%N\n" 201259*
或者
rm -i 201259*
或者,让文件完成来处理它:
rm -i 202259<kbd>TAB</kbd>
答案2
不讨论如何删除/移除文件(@waltinator 的回答应该足够了),而是发生了什么,以及如果你做同样的事情,可能再次发生什么。
要查看发生了什么,请启用命令执行跟踪(在终端) 和:
set -x
...然后,运行命令(在其末尾添加; jobs
以列出当前 shell 中的后台作业)像这样:
wget https://civitai.com/api/download/models/201259?type=Model&format=SafeTensor&size=pruned&fp=fp16; jobs;
...这将导致以下输出:
[1] 10218
[2] 10219
+ wget 'https://civitai.com/api/download/models/201259?type=Model'
[3] 10220
+ fp=fp16
+ format=SafeTensor
+ jobs
[1] Running wget https://civitai.com/api/download/models/201259?type=Model &
[2]- Running format=SafeTensor &
[3]+ Running size=pruned &
+ size=pruned
... 其中wget
传递了 URL'https://civitai.com/api/download/models/201259?type=Model'
并作为后台作业运行,即wget https://civitai.com/api/download/models/201259?type=Model &
... 和两个变量/参数format
和也size
被设置为format=SafeTensor
和size=pruned
在后台,即format=SafeTensor &
和size=pruned &
因为后台作业在具有单独进程 ID 的各自子 shell 中运行,它们的分配只在这些子 shell 中可用,并且在这些子 shell 终止后将不再可用/设置,因此您无法在当前父 shell 中调用它们 ... 您还将看到,第三个变量/参数fp
也被设置了fp=fp16
,但它在当前 shell 中设置了&
,因此它将可用,您可以用例如调用它:
$ echo "$fp"
+ echo fp16
fp16
...如果你jobs
再次跑步(由于wget
下载仍在进行中),如下所示:
$ jobs
+ jobs
[1]+ Running wget https://civitai.com/api/download/models/201259?type=Model &
...你只会看到一个作业在后台运行(另外两个已立即终止/完成)...如果你使用以下命令将剩余的工作放到前台:
fg
...然后,你应该看到上面提到的wget
命令仍然在运行,并且如果你等待它完成(因为我认为你没有,而且可能关闭了终端,过早地终止了后台作业),它应该如下所示:
$ fg
+ fg
wget https://civitai.com/api/download/models/201259?type=Model
--2023-11-01 09:38:57-- https://civitai.com/api/download/models/201259?type=Model
Resolving civitai.com (civitai.com)... 104.18.23.206, 104.18.22.206, 2606:4700::6812:17ce, ...
Connecting to civitai.com (civitai.com)|104.18.23.206|:443... connected.
HTTP request sent, awaiting response... 307 Temporary Redirect
Location: https://civitai-delivery-worker-prod-2023-10-01.5ac0637cfd0766c97916cefa3764fbdf.r2.cloudflarestorage.com/model/81744/epicphotogasmz.VG6S.safetensors?X-Amz-Expires=86400&response-content-disposition=attachment%3B%20filename%3D%22epicphotogasm_z.safetensors%22&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=2fea663d76bd24a496545da373d610fc/20231101/us-east-1/s3/aws4_request&X-Amz-Date=20231101T063857Z&X-Amz-SignedHeaders=host&X-Amz-Signature=bb14df26d6a222876d9890c0b61ad83ca2577514edf9a337254b2ba6e7980cd1 [following]
--2023-11-01 09:38:58-- https://civitai-delivery-worker-prod-2023-10-01.5ac0637cfd0766c97916cefa3764fbdf.r2.cloudflarestorage.com/model/81744/epicphotogasmz.VG6S.safetensors?X-Amz-Expires=86400&response-content-disposition=attachment%3B%20filename%3D%22epicphotogasm_z.safetensors%22&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=2fea663d76bd24a496545da373d610fc/20231101/us-east-1/s3/aws4_request&X-Amz-Date=20231101T063857Z&X-Amz-SignedHeaders=host&X-Amz-Signature=bb14df26d6a222876d9890c0b61ad83ca2577514edf9a337254b2ba6e7980cd1
Resolving civitai-delivery-worker-prod-2023-10-01.5ac0637cfd0766c97916cefa3764fbdf.r2.cloudflarestorage.com (civitai-delivery-worker-prod-2023-10-01.5ac0637cfd0766c97916cefa3764fbdf.r2.cloudflarestorage.com)... 104.18.8.90, 104.18.9.90, 2606:4700::6812:85a, ...
Connecting to civitai-delivery-worker-prod-2023-10-01.5ac0637cfd0766c97916cefa3764fbdf.r2.cloudflarestorage.com (civitai-delivery-worker-prod-2023-10-01.5ac0637cfd0766c97916cefa3764fbdf.r2.cloudflarestorage.com)|104.18.8.90|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2132625628 (2.0G)
Saving to: ‘201259?type=Model’
201259?type=Model 100%[==========================================================================================================>] 1.99G 2.81MB/s in 11m 34s
2023-11-01 09:50:32 (2.93 MB/s) - ‘201259?type=Model’ saved [2132625628/2132625628]
...这表明1.99G
已下载并保存为201259?type=Model
当前工作目录,并ls
应像这样列出:
$ LC_ALL=en_US ls -alh
+ LC_ALL=en_US
+ ls --color=auto -alh
total 2.0G
drwxrwxr-x 2 ubuntu ubuntu 4.0K Nov 1 09:38 .
drwxr-x--- 20 ubuntu ubuntu 4.0K Nov 1 09:50 ..
-rw-rw-r-- 1 ubuntu ubuntu 2.0G Oct 27 20:29 '201259?type=Model'
-rw-rw-r-- 1 ubuntu ubuntu 119K Nov 1 09:41 wget-log
注意URL 中的每个字符都&
被 shell 解释为作业控制表示发送上一个命令的运算符(其左侧的字符串)在后台执行...为了防止该行为,请像这样单引号 URL:
wget 'https://civitai.com/api/download/models/201259?type=Model&format=SafeTensor&size=pruned&fp=fp16'