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

  • 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 01: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
  • @terdon I need svn commands, not simple local commands. The files I want to delete were commited on svn, now I need to delete all the .csv.gz and .class files that are in svn, so I need to delete them from SVN, not just from my local repository. – Moksud Ahmed Jun 12 '16 at 13:29
  • @MoksudAhmed OK, I am not familiar with SVN. Wouldn't it be enough to delete the local files and then commit the changes? If not, please [edit] your question and add the SVN command for deleting files. – terdon Jun 12 '16 at 13:31
  • @terdon I added the svn command for removing a file from svn, by the way i'm not sure if it's enough just to delete the files and then commit, but we can try, if you tell me how to delete all the files with the command I added below my question. Thanks for the help. – Moksud Ahmed Jun 12 '16 at 14:31

1 Answers1

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
terdon
  • 100,812
  • 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