rm

Delete a list of files with find and grep

我是研究僧i 提交于 2021-02-05 12:48:14
问题 I want to delete all files which have names containing a specific word, e.g. "car". So far, I came up with this: find|grep car How do I pass the output to rm? 回答1: find . -name '*car*' -exec rm -f {} \; or pass the output of your pipeline to xargs : find | grep car | xargs rm -f Note that these are very blunt tools, and you are likely to remove files that you did not intend to remove. Also, no effort is made here to deal with files that contain characters such as whitespace (including

目录处理命令

十年热恋 提交于 2020-12-25 12:04:40
创建目录:mkdir mkdir -p [目录名] -p 递归创建 命令英文愿意:make directories 切换目录:cd cd [目录] 命令英文原意:change directory 简化操作: cd: 进入当前用户的家目录 cd 目标目录:进入目标目录 cd -:回到上一次所在的目录 cd ~:进入当前用户家目录 cd . :进入当前目录 cd . .:进入上一级目录 查看所在目录位置:pwd pwd 命令英文原意:print working directory 注:pwd查看的是绝对路径。 绝对路径:从根目录开始制定,一级一级递归查找。在任何 目录下,都能进入指定位置。 如: [root@localhost~]#cd /etc/ 相对路径:参照当前所在目录,进行查找。 如:[root@localhost~]#cd ../usr/local/src/ 删除空目录:rmdir rmdir [目录名] 命令英文原意:remove empty directories 删除文件或目录:rm rm -rf [文件或目录] -r:删除目录 -f:强制删除 命令英文原意:remove 复制命令:cp cp [选项] [原文件或目录] [目标目录] 命令英文原意:copy 选项: -r 复制目录 -p 连带文件属性复制 -d 若原文件是链接文件,则复制链接属性 -a 相当于-dpr

git如何移除某文件夹的版本控制

做~自己de王妃 提交于 2020-11-28 06:23:44
#目录结构如下 project bin lib src ...... #执行如下的操作 git add . git commit -m "add bin/ lib/ src/" git push origin master 突然发现原来 lib 目录不需要提交到版本库,但是现在远程已经存在该目录,what should I do.(吐出去的东西还能收回来吗) 万能的git啊,help me! 功夫不负有心人,找到了解决问题的方法,其实就是 git rm 的命令行参数。 git rm 命令参数 -n --dry-run Don’t actually remove any file(s). Instead, just show if they exist in the index and would otherwise be removed by the command. -r Allow recursive removal when a leading directory name is given. --cached Use this option to unstage and remove paths only from the index. Working tree files, whether modified or not, will be left alone.

How to delete multiple files at once in Bash on Linux?

对着背影说爱祢 提交于 2020-07-31 06:10:30
问题 I have this list of files on a Linux server: abc.log.2012-03-14 abc.log.2012-03-27 abc.log.2012-03-28 abc.log.2012-03-29 abc.log.2012-03-30 abc.log.2012-04-02 abc.log.2012-04-04 abc.log.2012-04-05 abc.log.2012-04-09 abc.log.2012-04-10 I've been deleting selected log files one by one, using the command rm -rf see below: rm -rf abc.log.2012-03-14 rm -rf abc.log.2012-03-27 rm -rf abc.log.2012-03-28 Is there another way, so that I can delete the selected files at once? 回答1: Bash supports all

git remove a file from remote repository

橙三吉。 提交于 2020-02-29 14:42:34
当你误提交一些文件的时候,比如log 之类的,这些事本地文件需要的,那么如何删除远程仓库的这些log,而不删除本地的文件呢。 git rm -r -- cached File-or-FolderName -r Allow recursive removal when a leading directory name is given. -- cached Use this option to unstage and remove paths only from the index. Working tree files, whether modified or not, will be left alone. -n或者 -- dry-run Don’t actually remove any file(s). Instead, just show if they exist in the index and would otherwise be removed by the command. git rm -r -n --cached "bin/" //-n:加上这个参数,执行命令时,是不会删除任何文件,而是展示此命令要删除的文件列表预览。 git rm File-or-FolderName #### 删除本地和repository git commit -m "Removed

Mac OS X restore files deleted by git rm

被刻印的时光 ゝ 提交于 2020-01-06 08:11:39
问题 i just messed up big. The way it happened is so emberassing that I won't write it down :) So here's my problem: Github Repop deleted Local repo files delete by git rm -r Local repo new initalized Is there any chance how to restore my data? Luckily it's in a very very early stage of this project. Regards 回答1: git reset HEAD If you don't have any uncommited changes you care about then use git reset --hard HEAD 回答2: I am not sure I completely understand the state of your local repo, but if all

How to remove a file whose name starts with '-' [duplicate]

和自甴很熟 提交于 2019-12-30 04:50:08
问题 This question already has answers here : How to remove files starting with double hyphen? (7 answers) rm cannot delete files starting with “--” [duplicate] (3 answers) Closed 5 years ago . After a mistake in a script I ended up with a file whose name starts with a dash, - : -myfile.txt I tried so far: rm -myfile.txt rm: illegal option -- m usage: rm [-f | -i] [-dPRrvW] file ... unlink file rm "-myfile.txt" rm: illegal option -- m usage: rm [-f | -i] [-dPRrvW] file ... unlink file rm "\-myfile