Group : Add current year collector.

This commit is contained in:
Dmitry Voronin 2024-01-27 19:42:37 +03:00
parent 442040a639
commit c7c3fae834
2 changed files with 23 additions and 2 deletions

View file

@ -36,3 +36,22 @@ function group_year() {
_iterate_targets process ${targets[@]}
}
# Copy files from current year to the named dir.
function group_year_current() {
local IFS=$'\n'
local targets=(${@})
[[ "${targets}" = "" ]] && targets=($(ls))
local today="$(date +%Y)"
mkdir ${today} 2> /dev/null
process() {
local year=$(stat --format=%y ${target})
year=${year%%-*}
[[ "${year}" = "${today}" ]] && cp -- ${target} ./${today}/
}
_iterate_targets process ${targets[@]}
}

View file

@ -211,6 +211,7 @@ Command|Description
---|---
`group_ext [FILES]`|Group files by extension.
`group_year [FILES]`|Group files and dirs by year.
`group_year_current`|Copy files from current year to the named dir.
## Help.
@ -267,9 +268,10 @@ Command|Description
`nix_unstable`|Switch to Unstable branch.
`nix_unstable_small`|Switch to Small Unstable branch (for server).
`nix_channel`|Display current channel.
`nix_update`|Update system (rebuild).
`nix_upgrade`|Upgrade system.
`nix_update [HOSTNAME]`|Update system (rebuild). Optionally force the hostname.
`nix_upgrade [HOSTNAME]`|Upgrade system. Applies after reboot. Optionally force the hostname.
`nix_clean`|Free up root space.
`nix_shell`|Spawn shell with nix environment, like LD support.
`shell`|Spawn temporary shell.
## Notify.