以下方法有什么问题(rm + xargs)
What is wrong in following approach (rm + xargs)
谁能告诉我以下以“#”开头的文件删除方式有什么问题。
目录中的文件:
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 : 参考以下问题
ls
可能会在多个列中列出文件,并且您的正则表达式也没有锚定到文件名的开头。包含空格的文件名也会有问题。
谁能告诉我以下以“#”开头的文件删除方式有什么问题。
目录中的文件:
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 : 参考以下问题
ls
可能会在多个列中列出文件,并且您的正则表达式也没有锚定到文件名的开头。包含空格的文件名也会有问题。