LinuxCommandLibrary

find2perl

translate find commands to Perl scripts

TLDR

Convert find to Perl

$ find2perl [directory] -name "[*.txt]"
copy
Generate script with execution
$ find2perl [.] -type f -exec cat {} \;
copy
Complex find expression
$ find2perl [/var] -mtime +[30] -name "[*.log]"
copy
Output to file
$ find2perl [.] -name "[*.bak]" > [cleanup.pl]
copy

SYNOPSIS

find2perl [paths] [predicates]

DESCRIPTION

find2perl translates find command expressions into equivalent Perl scripts. The generated script uses File::Find and produces the same results as the find command.
The tool helps users migrate from find to Perl for complex file processing tasks. The generated Perl code can be modified to add custom processing beyond what find supports.
find2perl bridges shell scripting and Perl programming for file system operations.

PARAMETERS

PATHS

Starting directories to search.
PREDICATES
find-style expressions.
-name PATTERN
Match filename pattern.
-type TYPE
File type (f, d, l).
-mtime N
Modification time.
-exec CMD
Execute command.
-print
Print matching paths.

CAVEATS

Not all find options supported. Generated code may need cleanup. Deprecated in newer Perl versions.

HISTORY

find2perl was included with Perl as a utility for translating find commands. It helped users understand Perl's File::Find module and convert existing shell scripts.

SEE ALSO

find(1), perl(1), File::Find(3pm)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community