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

8
  • find . -type f -name "*.class" -exec rm -f {} \; && find . -type f -name "*.csv.gz" -exec rm -f {} \; - Jun 11, 2016 at 14:23
  • Should I write this directly in the console ? Jun 11, 2016 at 14:28
  • ... or are you actually asking how to remove files from an SVN repository? Jun 11, 2016 at 15:43
  • @steeldriver I'm asking how to remove files from an svn repository. Could you help me please? Jun 12, 2016 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, 2016 at 13:11

1 Answer 1

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
4
  • 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 ? Jun 12, 2016 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, 2016 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" Jun 12, 2016 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, 2016 at 15:17

Not the answer you're looking for? Browse other questions tagged .