delete-file

Ansible: How to delete files and folders inside a directory?

不问归期 提交于 2019-12-03 00:25:34
问题 The below code only deletes the first file it gets inside the web dir. I want to remove all the files and folders inside the web directory and retain the web directory. How can I do that? - name: remove web dir contents file: path='/home/mydata/web/{{ item }}' state=absent with_fileglob: - /home/mydata/web/* Note: I've tried rm -rf using command and shell, but they don't work. Perhaps I am using them wrongly. Any help in the right direction will be appreciated. I am using ansible 2.1.0.0 回答1:

Git ignore deleted files

早过忘川 提交于 2019-12-02 23:16:26
I have a website project that has more than 50,000 unimportant files (to development) in some directories. /website.com/files/1.txt /website.com/files/2.txt /website.com/files/3.txt /website.com/files/etc.txt The stuff in /files is already in the repo. I want to delete all the files in /files on my local copy but I want git to ignore it so it doesn't delete them when I do a pull on the web server. Any ideas? Ignoring a whole directory didn't work. I had to do this: for i in `git status | grep deleted | awk '{print $3}'`; do git update-index --assume-unchanged $i; done Quang Van The code below

Shell command/script to delete files whose names are in a text file

為{幸葍}努か 提交于 2019-12-02 19:45:00
I have a list of files in a .txt file (say list.txt). I want to delete the files in that list. I haven't done scripting before. Could some give the shell script/command I can use. I have bash shell. while read -r filename; do rm "$filename" done <list.txt is slow. rm $(<list.txt) will fail if there are too many arguments. I think it should work: xargs -a list.txt -d'\n' rm Try this command: rm -f $(<file) If the file names have spaces in them, none of the other answers will work; they'll treat each word as a separate file name. Assuming the list of files is in list.txt , this will always work:

Remove File from all Commits

天涯浪子 提交于 2019-12-02 17:10:41
I have uploaded a font file that I don't have the rights to distribute to git hub several updates ago. I have a relatively inactive repository and I have the ability to notify all of my members if necessary. I've tried several of the solutions. I need to delete a file in my directory called Resources\Video\%font%.ttf where %font% is the name of the plain, italicized and bold versions of the font. What commands do I use? In that case you could to use Git Filter Branch command with --tree-filter option. syntax is git filter-branch --tree-filter <command> ... git filter-branch --tree-filter 'rm

Ansible: How to delete files and folders inside a directory?

主宰稳场 提交于 2019-12-02 15:47:50
The below code only deletes the first file it gets inside the web dir. I want to remove all the files and folders inside the web directory and retain the web directory. How can I do that? - name: remove web dir contents file: path='/home/mydata/web/{{ item }}' state=absent with_fileglob: - /home/mydata/web/* Note: I've tried rm -rf using command and shell, but they don't work. Perhaps I am using them wrongly. Any help in the right direction will be appreciated. I am using ansible 2.1.0.0 Mohan Kumar P Below code will delete the entire contents of artifact_path - name: Clean artifact path file:

Windows batch file to delete .svn files and folders

纵然是瞬间 提交于 2019-12-02 14:54:56
In order to delete all ".svn" files/folders/subfolders in "myfolder" I use this simple line in a batch file: FOR /R myfolder %%X IN (.svn) DO (RD /S /Q "%%X") This works, but if there are no ".svn" files/folders the batch file shows a warning saying: "The system cannot find the file specified." This warning is very noisy so I was wondering how to make it understand that if it doesn't find any ".svn" files/folders he must skip the RD command. Usually using wild cards would suffice , but in this case I don't know how to use them, because I don't want to delete files/folders with .svn extension,

Python3 project remove __pycache__ folders and .pyc files

主宰稳场 提交于 2019-12-02 13:52:56
What is the BEST way to clear out all the __pycache__ folders and .pyc/.pyo files from a python3 project. I have seen multiple users suggest the pyclean script bundled with Debian, but this does not remove the folders. I want a simple way to clean up the project before pushing the files to my DVS. V. Gamula You can do it manually with the next command: find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf This will remove all *.pyc files and __pycache__ directories recursively in the current directory. I found the answer myself when I mistyped pyclean as pycclean: No command 'pycclean'

kohana3.0 how to completely delete image file?

不问归期 提交于 2019-12-02 11:24:18
问题 I have a kohana3.0 content and files management system, and I would like to be able to completely delete images from database, and from my folder where I have uploaded them, when a user deletes an image. Now I use for image deletion: public function delete($id = NULL) { parent::delete($id); unlink($this->path); } this in the image model. But it doesn't actually delete my image at all. How can an image file be deleted in kohana 3.0? 回答1: I have no idea about kohana, but the unlink() function

Find and delete specific file and sub directory within a directory using Python

烈酒焚心 提交于 2019-12-02 11:15:31
I am trying to automate a search and delete operation for specific files and folder underneath a specific folder. Below is the folder structure which I have: Primary Directory is MasterFolder, which includes multiple sub directories which are Child Folders Fol1, Fol2, Fol3, Fol4 the sub directories may vary folder to folder. The Sub folders have more files and subfolders. ExL Fol1 holds someFilesFolder, sometext.txt, AnotherFilesFolder same applies to other Fol2,Fol3 etc sub directories under the MasterFolder. Now what I would like to do is I wound want to scan the MasterFolder and go through

kohana3.0 how to completely delete image file?

谁说我不能喝 提交于 2019-12-02 06:05:01
I have a kohana3.0 content and files management system, and I would like to be able to completely delete images from database, and from my folder where I have uploaded them, when a user deletes an image. Now I use for image deletion: public function delete($id = NULL) { parent::delete($id); unlink($this->path); } this in the image model. But it doesn't actually delete my image at all. How can an image file be deleted in kohana 3.0? I have no idea about kohana, but the unlink() function is how files are deleted in PHP. If this isn't working, it is possible you just have a permissions problem