Had a folder with about 350 property files, but with only 150 of them having a valid file name. No problem finding the files with a valid file name using find in combination with regex
find . -regex '.*__.*properties'
Problem is that I do not want to find the files with valid file names, I needed the ones with invalid names, but all the time regex is powerfull doing almost anything except excluding phrases and such (as I have read in various sources found by Google) I had to find a workaround.
So here goes, all from the directory where the files are located
- ls > allfiles.txt create a file with all filenames
- perl -pi -e ‘s#.*__.*properties##g’ allfiles.txt Remove all valid filenames
- perl -pi -e ‘s#^\n##g’ allfiles.txt Turned out that I did not remove the newlines, so to get rid of all the blank lines I needed to issue this command as well.
- for i in `cat allfiles.txt`; do svn delete $i; done This oneliner loops through the file, for each line delete the file from subversion (which deletes the file for me)
Voila! Pleased with myself 🙂