删除所有 docker 容器:
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
Run Code Online (Sandbox Code Playgroud)
或者这也会删除所有 docker 容器:
docker ps -q -a | xargs docker rm
Run Code Online (Sandbox Code Playgroud)
删除没有标签的镜像,即删除名称所在的位置docker images(来自如何删除没有标签的 Docker 镜像?):REPOSITORY<none>
docker rmi $(docker images -f dangling=true -q)
Run Code Online (Sandbox Code Playgroud)
但是在删除所有“悬空”图像和容器后,当我执行 a 时docker images,仍然有大量图像我不再使用并想要删除:
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tofufu latest 9bcb9d31a3f8 17 hours ago 900 MB
alvations/mosesdecoder ubuntu-basic 245c85d5fef1 5 days ago 2.22 GB
ubuntu-basic latest 245c85d5fef1 5 days ago …Run Code Online (Sandbox Code Playgroud) .git我有一个 git 存储库,Rift我正在尝试删除它。在尝试运行时rm -rf,我收到错误:rm: cannot remove 'Rift/.git/objects/pack': Directory not empty。
当我导航到目录树的底部时,我发现一个隐藏文件,名为 ,.fuse_hidden后跟一串数字和字母(可能是十六进制)。我可以手动删除此文件,但一旦删除它,就会在其位置创建另一个附加了不同数字和字母字符串的文件。
我已经尝试过rm .git/objects/pack/* && rm -rf .git,,sudo rm -rf .git和,chmod -w .git/objects/path但killall git都没有成功。
我有一个单线程程序(C++,Win32,NTFS),它首先创建一个相当长的临时文件,关闭它,打开以进行读取,读取,再次关闭并尝试使用删除DeleteFile().
通常它顺利进行,但有时会DeleteFile(失败,并GetLastError()返回ERROR_ACCESS_DENIED.文件不是只读的.它发生在任何大小的文件上,但概率随文件大小而增加.
什么可能锁定文件的想法?我尝试使用WinInternals工具进行检查,发现没有任何可疑之处.
我看过诸如清空目录的最佳方法之类的问题?
但我需要知道,
除了.zip找到的任何文件之外,删除目录中找到的所有文件的最快方法是什么.
在这里闻到像linq ......还是什么?
通过说最快的方式,我的意思是最快的执行时间.
我的Panasonic相机使用其愚蠢的PHOTOfunSTUDIO来导入照片.它根据拍摄照片的日期名称创建文件夹,并分别将照片导入这些文件夹.到现在为止还挺好.但是如果我在从相机中删除所有旧图片之前再次导入,则会通过添加名称后缀(002),(003),...再次导入旧图片,无论我如何更改该软件的设置.
我的问题:如何从这些文件夹中删除所有具有名称后缀的文件?
例如,这是一个文件夹:
D:\Photos\2011\2011-12-01>dir /b
20111201_184550(002).cont
20111201_184550(002).iis
20111201_184550(002).m2ts
20111201_184550(002).tmb
20111201_184550.cont
20111201_184550.iis
20111201_184550.m2ts
20111201_184550.tmb
Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,您需要将照片保存到SD卡,然后用户可以选择如何处理它.删除,保存或发送.如果按删除键.File.delete()当我在画廊中查看时,我称之为删除文件,然后当我稍后回去时,我看到一个黑色图像,说文件无法加载.该图像是我之前尝试删除的图像.这有什么问题,为什么它不会完全消失?
我如何保存图像:
public static File getOutputMediaFile(byte[] data){
image= BitmapFactory.decodeByteArray(data, 0, data.length);
File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "FrontFlash");
// Create the storage directory if it does not exist
if (!mediaStorageDir.exists()){
if (!mediaStorageDir.mkdirs()) return null;
}
// Create a media file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
File mediaFile;
mediaFile = new File(mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg");
return mediaFile;
}
@Override
public void onPictureTaken(byte[] data, Camera camera){
pictureFile = Util.getOutputMediaFile(data);
if (pictureFile == null){
Toast.makeText(this, …Run Code Online (Sandbox Code Playgroud) 我创建了一个属性文件,我想加密保留相同的文件夹加密属性文件并删除原始属性文件.当我第一次在我的java应用程序上执行此操作时,它确实正确.但是,当我再次执行此操作时,它不会删除创建的原始属性文件.当我尝试手动删除它时,它再次尝试消息说"由于文件在java(TM)平台SE二进制文件中打开,因此操作无法完成.关闭文件并重试." 关闭我的应用程序后,可以手动删除它.我的代码如下.问题在于propfile123.delete().我该如何解决这个问题.
//Encrypt the property file
Encrypt_Decrypt encrpt= new Encrypt_Decrypt("AES/ECB/PKCS5Padding","properties\\"+name_of_propertice_file+".properties", mstr_pass);
try {
encrpt.encrypt();
} catch (Exception ex) {
Logger.getLogger(Secure_File.class.getName()).log(Level.SEVERE, null, ex);
}
//delete the original properties file
File propfile123= new File("properties\\"+name_of_propertice_file+".properties");
System.out.println(propfile123.exists()); // always return true
System.out.println(propfile123.delete()); //here returns false when I call at second time to this method.
Run Code Online (Sandbox Code Playgroud) 我正在开发一个 python 脚本,它将文件上传到我的驱动器中的特定文件夹,正如我注意到的那样,驱动器 api 为此提供了一个很好的实现,但我确实遇到了一个问题,我如何一次删除多个文件?
我尝试从驱动器中抓取我想要的文件并组织它们的 ID,但没有运气......(下面的片段)
dir_id = "my folder Id"
file_id = "avoid deleting this file"
dFiles = []
query = ""
#will return a list of all the files in the folder
children = service.files().list(q="'"+dir_id+"' in parents").execute()
for i in children["items"]:
print "appending "+i["title"]
if i["id"] != file_id:
#two format options I tried..
dFiles.append(i["id"]) # will show as array of id's ["id1","id2"...]
query +=i["id"]+", " #will show in this format "id1, id2,..."
query = query[:-2] #to …Run Code Online (Sandbox Code Playgroud) python google-api delete-file google-drive-api google-api-python-client
当删除管道中较早创建的文件时,SnakeMake 似乎并不认为这是一个问题,只要后面的文件还在:
rule All:
input: "testC1.txt", "testC2.txt"
rule A:
input: "{X}{Y}.txt"
output: "{X}A{Y}.txt"
shell: "cp {input} {output}"
rule B:
input: "{X}A{Y}.txt"
output: "{X}B{Y}.txt"
shell: "cp {input} {output}"
rule C:
input: "{X}B{Y}.txt"
output: "{X}C{Y}.txt"
shell: "cp {input} {output}"
Run Code Online (Sandbox Code Playgroud)
将此 SnakeFile 保存在 test.sf 中并执行以下操作:
rm testA*.txt testB*.txt testC*.txt
echo "test1" >test1.txt
echo "test2" >test2.txt
snakemake -s test.sf
# Rerun:
snakemake -s test.sf
# SnakeMake says all is up to date, which it is.
# Remove intermediate results:
rm testA1.txt
# Rerun:
snakemake …Run Code Online (Sandbox Code Playgroud)