gpt4 book ai didi

linux - 以下方法有什么问题(rm + xargs)

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

任何人都可以告诉我以下以“#”开头的文件删除方式有什么问题。

目录中的文件:

ola@ola:~/.scratch/hmm$ ls
five #four #one six #three #two
ola@ola:~/.scratch/hmm$

ola@ola:~/.scratch/hmm$ ls . |grep "#.*" |xargs rm -rf
ola@ola:~/.scratch/hmm$ ls
five six
ola@ola:~/.scratch/hmm$

Ps : 引用以下问题

Bash: How do I delete all my textfiles starting with #?

最佳答案

ls 可能会在多个列中列出文件,并且您的正则表达式也没有锚定到文件名的开头。包含空格的文件名也会有问题。

关于linux - 以下方法有什么问题(rm + xargs),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37021224/

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