usedfiles – executes command and prints files, used during the execution.

Synopsis

usedfiles [-t TMPDIR] [-a] [-k] [-s] [-f OUTCOMFILE] [-o OUTUSEDFILE] [--] CMD
usedfiles --help|--version

Description

usedfiles prints the names of files, used by arbitrary command CMD.

Utility launches given CMD with strace(1) (mandatory version >=4.10) to track down opened and executed files, opened directories during the work of command CMD. Relying on strace(1) as data source, usedfiles thus currently works only on Linux.

CMD can be arbitrary command line with several words.

Temporary directory (/tmp/ by default) is used to store a trace during the work of target command CMD. The trace is filtered with sed(1), egrep(1), sort(1) and uniq(1) to extract file names.

By default (unless option -a is given) files from these directories are not printed:

/proc/
/sys/
/tmp/
/run/
/dev/

-- token is used to separate options of usedfiles itself from target command.

Mounted file system /proc/ must be available, as strace(1) will not provide needed info in its absence. Availability of that virtual file system is checked before launch.

Options

-a
Print all used files regardless of their layout in filesystem, including temporary files, pids, proc entries and so on.
-t TMPDIR
Temporary directory to use. /tmp/ by default.
-k
Do not remove temporary files: unfiltered execution trace and, if -s is given, the original output of target command.
-s
Hide the output of target command and print out only used file names. The original output is redirected to temporary file, which will be deleted automatically without -k option.
-f OUTCOMFILE
Redirect the output of target command to the given OUTCOMFILE. The file is not deleted in any way, with or without -k option.
-o OUTUSEDFILE
Redirect the output, containing used files, to the given OUTUSEDFILE.
--version
Print version and exit with 0 code.
--help
Print short help description and exit with 0 code.

Limits

Arguments of options -t, -f and -o cannot start with '-' symbol.

See also

strace(1), sed(1)