简体   繁体   English

如何从Linux中的shell中删除以._开头的所有文件?

[英]How can I delete all files starting with ._ from the shell in Linux?

As the title really. 作为标题真的。 I have copied over a number of files to a Raspberry Pi from a Mac. 我已经从Mac上复制了许多文件到Raspberry Pi。 This has resulted in lots of superfluous files starting with the prefix ._ . 这导致了许多以前缀._开头的多余文件。 I want to delete every file in a folder that starts with ._ . 我想删除以._开头的文件夹中的每个文件。 How would I do this? 我该怎么做?

Try something like: 尝试类似的东西:

cd /path/to/directory; \rm -rf ._*

OR if there are recursive files with in subfolders then try: 或者,如果子文件夹中有递归文件,请尝试:

find /path/to/directory -name "._*" -type f -print0| xargs -0 \rm -rf

The EASY WAY: 简单方法:

to remove files starting with a string like : example-1.html, example-2.js, ... 删除以字符串开头的文件,例如:example-1.html,example-2.js,...

 rm examp*

to remove directories starting with a string like : example-1/, example-1-1-0/, example-2/, ... 删除以字符串开头的目录,例如:example-1 /,example-1-1-0 /,example-2 /,...

rm -rf examp*

PS: PS:

-r for recursively -r用于递归

-f for force (the erasing as used for not empty directories) -f for force(用于非空目录的擦除)

that's all folks! 这是所有人!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在没有find的情况下在linux shell脚本中根据日期查找和删除文件? - How can I find and delete files based on date in a linux shell script without find? 如何删除外壳中除“ 1.jpg”以外的所有jpg文件 - How can I delete all jpg files except “1.jpg” in shell 如何删除Linux代码文件中未使用的文件? - How can I delete files that are not used in code files in linux? 如何将文件从谷歌云计算引擎(linux 终端)复制到谷歌云 shell? - How can I copy files from a Google Cloud Compute engine(linux terminal) to google cloud shell? 我想删除linux中的所有文件和目录 - I wanna to delete all files and directories in linux Linux Shell:如何从输入文件中删除以模式开头的字符串 - Linux shell: how to remove a string starting with a pattern from an input file 如何使用Linux Shell脚本从1-500生成大小为1mb的随机文件 - How can I generate random files with size 1mb each from 1-500 using linux shell script 我如何删除“ <MAXROWS/> 通过linux / unix命令从目录中所有30个文件中获取字符串? - How can i remove “<MAXROWS/>” string from all 30 files in my directory through linux / unix command? 在Linux中,如何复制不以给定字符串开头的所有文件? - In Linux, how to copy all the files not starting with a given string? 如何在 Linux 中创建脚本以删除目录中的所有文件,只剩下 5 个文件 - How to create a script in Linux to delete all files from the directory expect only left 5 files
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM