NAME
finddo - Search for files and run command
VERSION
This document describes version 0.002 of main (from Perl distribution App-finddo), released on 2017-08-16.
SYNOPSIS
Usage:
% finddo [options] [command] ...
DESCRIPTION
EARLY RELEASE, MANY FEATURES ARE NOT YET IMPLEMENTED OR DEFINED.
The finddo utility is a convenient alternative for the Unix find command, for the more specific purpose of running a command with the matching files as arguments. It provides convenience options such as --largest
, --newest
, or --media
, --audio
, --video
, or -n
. So to play the 3 newest songs, instead of doing:
ls --sort=t *.mp3 *.m4a *.flac *.ogg 2>/dev/null | head -n3 | xargs mpv --
and still be tripped by quoting of problematic filenames, you can just say:
finddo --newest --audio -n3 -- mpv --
OPTIONS
*
marks required options.
Main options
- --audio
- --command-json=s
-
See
--command
. - --command=s@
-
Can be specified multiple times.
- --dirs
- --exists
- --files
- --image
- --largest
- --max-result=s, -n
- --media
- --newest
- --oldest
- --smallest
- --sort=s
-
Valid values:
["mtime","-mtime","size","-size","name","-name"]
- --video
- -d
-
Shortcut for --dirs.
See
--dirs
. - -D
-
Shortcut for --no-dirs.
See
--dirs
. - -f
-
Shortcut for --files.
See
--files
. - -F
-
Shortcut for --no-files.
See
--files
.
Output options
- --format=s
-
Choose output format, e.g. json, text.
Default value:
undef
- --json
-
Set output format to json.
- --naked-res
-
When outputing as JSON, strip result envelope.
Default value:
0
By default, when outputing as JSON, the full enveloped result is returned, e.g.:
[200,"OK",[1,2,3],{"func.extra"=>4}]
The reason is so you can get the status (1st element), status message (2nd element) as well as result metadata/extra result (4th element) instead of just the result (3rd element). However, sometimes you want just the result, e.g. when you want to pipe the result for more post-processing. In this case you can use `--naked-res` so you just get:
[1,2,3]
Other options
COMPLETION
The script comes with a companion shell completer script (_finddo) for this script.
bash
To activate bash completion for this script, put:
complete -C _finddo finddo
in your bash startup (e.g. ~/.bashrc). Your next shell session will then recognize tab completion for the command. Or, you can also directly execute the line above in your shell to activate immediately.
It is recommended, however, that you install modules using cpanm-shcompgen which can activate shell completion for scripts immediately.
tcsh
To activate tcsh completion for this script, put:
complete finddo 'p/*/`finddo`/'
in your tcsh startup (e.g. ~/.tcshrc). Your next shell session will then recognize tab completion for the command. Or, you can also directly execute the line above in your shell to activate immediately.
It is also recommended to install shcompgen (see above).
other shells
For fish and zsh, install shcompgen as described above.
HOMEPAGE
Please visit the project's homepage at https://metacpan.org/release/App-finddo.
SOURCE
Source repository is at https://github.com/perlancar/perl-App-finddo.
BUGS
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=App-finddo
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
SEE ALSO
find. Unix command.
AUTHOR
perlancar <perlancar@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2017 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.