Quellcode durchsuchen

Post: prunefiles

bryan vor 5 Jahren
Ursprung
Commit
aedad65edc
1 geänderte Dateien mit 44 neuen und 0 gelöschten Zeilen
  1. 44 0
      blog.bryanroessler.com/_posts/2020-04-01-prune.md

+ 44 - 0
blog.bryanroessler.com/_posts/2020-04-01-prune.md

@@ -0,0 +1,44 @@
+---
+layout: post
+title: prunefiles
+subtitle: An easy way to keep your repositories clean
+tags:
+  - prune
+  - git
+  - repositories
+  - fedora
+---
+
+## Overview
+
+Here's a simple script/function to keep *n* number of the latest files that match your argument(s) in the current directory. I wrote this in order to periodically clean rpm and deb repositories. It will create file lists by matching one or more input arguments and keep only the latest file from each list. The number of files to be kept for each matching list can be set using `-k`. The file can safely be sourced as a function.
+
+### Code
+
+[prunefiles](https://git.bryanroessler.com/bryan/scripts/raw/master/prunefiles):
+~~~bash
+{% insert_git_code https://git.bryanroessler.com/bryan/scripts/raw/master/prunefiles %}
+~~~
+
+### Example
+~~~bash
+$ ls
+Package-25-1.rpm
+Package-25-2.rpm
+Package-25-3.rpm
+Package-25-4.rpm
+Package-26-1.rpm
+Package-26-2.rpm
+Package-27-1.rpm
+Package-27-2.rpm
+$ prunefiles Package-25 Package-27
+$ ls
+Package-25-4.rpm
+Package-26-1.rpm
+Package-26-2.rpm
+Package-27-2.rpm
+~~~
+
+### Conclusion
+
+I have provided a script that keeps *n* number of latest files in the current directory that match any number of input argument(s).