You are not logged in.
When dealing with timestamped files, it is sometimes nice to be able to cleanup unnecessary files while keeping some for archive purposes. Could not find better option than to write small script for that. It searches directory content for timestamped files and lists only files for last N days/months/years. Optionally it allows to --invert filter and --delete filtered files:
https://gitlab.com/student/timestamps-archive
# list top 10 timestamped files in current directory
timestamps-archive.py --format "archive_%Y-%m-%d.zip" --top 10
# first timestamped file from last 12 months
timestamps-archive.py --format "%Y-%m-%d" --months 12
# delete timestamped files except latest 5 and last 10 years
timestamps-archive.py --format "%Y-%m-%d" --top 5 --years 10 --invert --delete
# print help
timestamps-archive.py -h
usage: timestamps-archive.py [-h] [--path PATH] [--format FORMAT] [--top TOP]
[--days DAYS] [--months MONTHS] [--years YEARS]
[--invert] [--delete]
Daily/monthly/yearly archive filter for timestamped files/directories
optional arguments:
-h, --help show this help message and exit
--path PATH files path, default is current directory
--format FORMAT date/time format, default is %Y-%m-%dT%H:%M:%S
--top TOP include TOP files
--days DAYS include number of DAYS
--months MONTHS include number of MONTHS
--years YEARS include number of YEARS
--invert invert filter
--delete delete filtered files/directories
Offline
studentik, is this just on the filenames, or do you look at mtime/atime? If the latter, you should really just use find as it has flags for file times in certain ranges.
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
studentik, is this just on the filenames, or do you look at mtime/atime? If the latter, you should really just use find as it has flags for file times in certain ranges.
This looks for timestamp in names. Regarding find, I don't know if that is possible, since whether or not file should end up in list depends on existance/absence of another files, not current time. Let's say we don't have archive for January 1st, but do have for January 2nd, filtering --years should keep this January 2nd since it is first existing timestamp for particular year.
Offline
Well I was thinking find piped to head/sed or the like for restricting the number of results, but yes, if this is just about dates in the names of files, find wouldn't help.
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
I lied, I have a little AUR helper; this is all it does:
aur pkgname:
git clone https://aur.archlinux.org/$1.git
I also have a little ABS helper,
abs pkgname:
git clone git://git.archlinux.org/svntogit/packages.git --{single-,}branch {packages/,}$1
makepkg-optimize · indicator-powersave · pantheon-{3d,lite} · {pantheon,higan}-qq
Offline
How many AUR packages do you manage with your "little" helper?
Just wondering.
Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby
Honest Alad's Package Emporium—Now with added bugs! (Grand reopening: December 1st 2018)
Offline
git clone https://aur.archlinux.org/$1.git
I have almost the same:
#!/bin/sh
if [ -z "$1" ]; then
exit 1
fi
git clone "https://aur.archlinux.org/$1"
Offline
How many AUR packages do you manage with your "little" helper?
lol, "manage" may be too strong a word; it's downloaded a few dozen packages.
EDIT: If you were asking about the packages I maintain in the AUR; I "manage" those in a couple of git repositories of their own. All my published AUR packages have been managed with git since.. aur 4?.
if [ -z "$1" ]; then exit 1 fi
ooh, mine just breaks!
Last edited by quequotion (2019-12-03 10:31:58)
makepkg-optimize · indicator-powersave · pantheon-{3d,lite} · {pantheon,higan}-qq
Offline
Suggested improvement:
#!/bin/bash
if [[ -z $1 ]]; then
echo "The trash heap of Arch. Dig around enough and maybe you will find some gold."
else
git clone https://aur.archlinux.org/"$1".git
fi
Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby
Honest Alad's Package Emporium—Now with added bugs! (Grand reopening: December 1st 2018)
Offline
The quotes around $1 don't really help much - they just change the type of problem you'd face if you pass a first parameter with spaces in it - but it really doesn't matter as package names can't have spaces.
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
That reminds me of an AUR pkgbuild I saw which had depends like 'foo bar'. I guess that's for the grr thread...
Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby
Honest Alad's Package Emporium—Now with added bugs! (Grand reopening: December 1st 2018)
Offline
The trash heap of Arch. Dig around enough and maybe you will find some gold.
Is that a proposal for the AUR FAQ?
I support this proposal. It makes clear the risks involved; the dumpster diving metaphor is excellent: this may give you cholera, or hepatitis, not to mention a sore stomach (and honestly a few headaches).
Also fine documentation for a little AUR helper.
they just change the type of problem you'd face if you pass a first parameter with spaces in it
It just does one pkgname at a time; someone may attempt multiple pkgnames in a single call. That won't work without a loop; and is going to cause some unspecified behavior as is.
Maybe mandatory single pkgname mode is best anyway ($1 without quotes; relies on user not supplying $1 as a string with a space in it using their own quotes; silently drops other parameters if say, someone tried to aur multiple-bzr aurpkgs-git atonce-hg)?
Last edited by quequotion (2019-12-03 13:20:36)
makepkg-optimize · indicator-powersave · pantheon-{3d,lite} · {pantheon,higan}-qq
Offline
If someone quoted multiple packages in one string they only have themselves to blame...
Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby
Honest Alad's Package Emporium—Now with added bugs! (Grand reopening: December 1st 2018)
Offline