Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the purpose of the curly braces after a perl -e line

Tags:

find

perl

I know some real perl basics, and I've been using this one liner to rename files:

find . -type f -exec perl -e 'rename($_,lc) for @ARGV' {} \;

The find passes a list of files to the perl one liner, which then renames them lowercase -- but whats the {} for?

like image 821
Will Avatar asked Aug 18 '11 17:08

Will


2 Answers

The '{}' argument is part of the "find" command, not the "perl" command.

Per the find man page documentation, the token '{}' is replaced with the name of the current file being processed so it can be used by the target of the "exec" arguments, which are, in this case, "perl -e ...".

like image 139
maerics Avatar answered Nov 15 '22 07:11

maerics


It comes from find, and will be substituted by the file(s) name found. It will execute perl like:

perl -e 'rename($_,lc) for @ARGV'filename

like image 30
sidyll Avatar answered Nov 15 '22 07:11

sidyll