GNU xargs
xargs is awesome. Send it some data
parameters, it'll make very few invocations of a cmdline
with data
as the arguments.
Consider moving files older than one year to directory 'd', the simplest and most efficient method that comes to my mind is using find
and xargs
:
$ find . -maxdepth 0 -mtime +365 | xargs mv -t d
Nice isn't it.
sleeping
There is one lacking feature that I know of with the xargs
program, this is that it doesn't by default delay between invocations of cmdline, that is, until I did a bit of minor hacking and in a couple of lines I'd produced a patch file. I've not make doc changes so I doubt it'll make it past a git commit. Anyway, it's available in /code/findutils.
It's really quite simple, just adds --delay/-D
to the options.
For example, lets finger three people once every five seconds (your system might have a different user UID starting point than 500 but this is just purely for example):
awk -F: '{ if( $3 > 500 ) { print $1 } }' /etc/passwd | xargs -l3 -D5 finger
Anyway, I'm quite pleased with this, I don't know why I hadn't thought of it sooner really as it's very simple.