简体   繁体   English

Linux Shell-删除名称以.git开头的文件夹,该文件夹是内部文件夹的一部分

[英]Linux Shell - Delete a folder whose name startwith .git which is a part of inner folders

here is a sample directory structure/tree 这是示例目录结构/树

main_directory-|- folder1
               |- folder2
               |- folder3
               |- folder4 -|- .git
                           |- my_project
                           |- some_other_files

assume I'm in the main directory. 假设我在主目录中。

admin@admin:~/$ cd main_directory
admin@admin:~/main_directory$

here I want to execute some command which will delete all folders whose name starts with .git RECURSIVELY. 在这里,我想执行一些命令,该命令将删除名称以.git RECURSIVELY开头的所有文件夹。

What I was trying = rm -r .git* its not working. 我正在尝试= rm -r .git*它不起作用。 or may be using someother command, eg mv but I dont have any clue about that. 或可能正在使用其他命令,例如mv但我对此没有任何线索。

problem is I have many such folders and each of them has one or more .git so I cannot go manually in each directory and delete git folder. 问题是我有很多这样的文件夹,并且每个文件夹都有一个或多个.git所以我无法手动进入每个目录并删除git文件夹。

find . -name .git -exec rm -r {} \\;

暂无
暂无

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

相关问题 Linux, shell 脚本] 如何通过按文件夹名称搜索来动态删除文件夹 - Linux, shell script] How to dynamically delete folders by searching by folder name Shell脚本删除另一个文件夹中不存在的文件和文件夹 - Shell script to delete files and folders that don't exist in another folder 从另一个文件夹linux shell中删除一个文件夹中的文件 - removing files which are in one folder from another folder linux shell 将所有文件夹和文件移动到 Linux 目录中具有相同主题名称的文件夹中 - move all the folders and files to the folder with the same subject name in the directory Linux 从Linux中包含文件夹名称的多个文件夹复制文件 - Copy files from multiple folders with including folder name in Linux Linux cron作业无法执行在Shell中工作的部分脚本 - Linux cron job fails to execute part of script which works in shell Linux命令删除除.git文件夹以外的所有文件? - Linux command to delete all files except .git folder? Linux shell脚本:创建一个包含当前日期名称的文件夹 - Linux shell script : make a folder with the current date name linux shell 获取一个脚本<latest file>的<particular name>在文件夹中</particular></latest> - linux shell script to fetch a <latest file> of <particular name> in a folder 删除linux目录中的所有文件夹和文件,除了一个文件夹和该文件夹中的所有内容 - delete all folders and files within a linux directory except one folder and all contents inside that folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM