1

I'm trying to delete all .class and .csv.gz files from my svn directory and all subdirectories. Can anyone tell me how to do it automatically with a command ? I have RabbitSVN installed on my Ubuntu.

The svn command for removing a file is: svn delete fileName

marked as duplicate by steeldriver, Eric Carvalho, Videonauth, Sergiy Kolodyazhnyy, muru command-line Jun 13 '16 at 21:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • find . -type f -name "*.class" -exec rm -f {} \; && find . -type f -name "*.csv.gz" -exec rm -f {} \; - – Knud Larsen Jun 11 '16 at 14:23
  • Should I write this directly in the console ? – Moksud Ahmed Jun 11 '16 at 14:28
  • ... or are you actually asking how to remove files from an SVN repository? – steeldriver Jun 11 '16 at 15:43
  • @steeldriver I'm asking how to remove files from an svn repository. Could you help me please? – Moksud Ahmed Jun 12 '16 at 1:04
  • @MoksudAhmed on the remote repository or on the local copy on your file system? Basically, steeldriver is asking whether you need svn commands or simple, local rm. – terdon Jun 12 '16 at 13:11
1

You can delete all the relevant files from your local system with:

find /path/to/dir -type f \( -name "*.class" -o -name '*.csv.gz' \) -delete

If you then commit the changes, the remote files should also be removed. Alternatively, you can run svn delete on each of the files:

find /path/to/dir -type f \( -name "*.class" -o -name '*.csv.gz' \) -exec svn delete {} \;

You could probably also just do this directly:

shopt -s globstar
svn delete **/*.class **/*.csv.gz
  • For the 1st and 2nd option, should I write all the line directly in the console ? As my svn folder is in Desktop/SVN/, should I modify the line with "/Desktop/SVN" instead of "/path/to/dir", right ? – Moksud Ahmed Jun 12 '16 at 15:02
  • @MoksudAhmed yes and yes. The command should be run directly from the terminal and /path/to/dir should be ~/Desktop/SVN (note the ~, /Desktop would be a directory called Desktop that's in /). – terdon Jun 12 '16 at 15:03
  • I think that the 3rd solution is the best for me, I tried it with an example (I added 3 files called .tralala in different folders of my svn and with your solution I succesfully deleted them from svn), but now that I launched the command with the .class files, I received this output: ''bash: /usr/bin/svn: Argument list too long" – Moksud Ahmed Jun 12 '16 at 15:16
  • @MoksudAhmed in that case, use the find approach. The "too long" error is because you are trying to delete too many files at once. Using find avoids that. – terdon Jun 12 '16 at 15:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.