0

I have this command (KSH)

find <path> -regextype posix-extended -type f -regex '.*/txt' -exec ls -l --full-time \{\} \;
| sort -bnr

So, I'm reading and deciphering the command above so far what I know is that

-regextype posix-extended

this just changes the regextype to posix-extended

-type f

this only return files

-regex '.*/txt'

this is just regular expression

-exec ls -l --full-time

executes ls -l --full-time

\\{\\}

this one I don't get. What does it do? What I know is that I need to end -exec with {} \; but why there's backslash inside the curly braces?

1
  • @muru Thank you! I guess I never looked enough in the man page to see this. smh. PS. I don't know how to upvote your comment though :(
    – Clem
    Feb 15, 2020 at 6:15

2 Answers 2

2

What I know is that I need to end -exec with {} \; but why there's backslash inside the curly braces?

The backslashes remove the special meaning of the following character, like here:

$ echo $SHELL
/bin/bash
$ echo \$SHELL
$SHELL

That's what they do here, too, except that in sh-like shells {} isn't special to begin with, so they're not needed. They would be needed in at least the fish shell, where the plain {} gets removed, or if you had something that looks like a brace expansion in Bash/ksh/zsh, but didn't want to expand it. (e.g. echo \{foo,bar\} vs echo {foo,bar})

0

The {} get substituted by the entities found by find. At least in bash the escaping of the {} is not nessesary so a ...-exec ls -l --full-time {} \; might work as well.

Not the answer you're looking for? Browse other questions tagged .