-1

i need to execute in background this command

sudo find '/abc/abc/' -type f -exec sed 's/domain1\it/domain2\com/g' '{}' \; . &

but I have two issues:

find: paths must precede expression: `.'
find: possible unquoted pattern after predicate `-exec'?

And again, there are other smart ways to "find and replace" more fastly, to do this: sudo find '/abc/abc/' -type f -exec sed 's/domain1\it/domain2\com/g' '{}' ; & maybe with grep?

Thanks

5
  • 1
    What's the . supposed to be, there?
    – muru
    Apr 29, 2021 at 18:09
  • Is /abc/abc/ an existing directory? Where are the files to be searched. The "`paths must preceed
    – waltinator
    Apr 29, 2021 at 18:19
  • Ok, removed "." before &, abc/abc it is ok, but with "/abc/abc/" it shows the fully process and i don't want it, i need it in background Apr 29, 2021 at 18:40
  • @DantinoEsposito background processes still write their standard output and error streams to the terminal - and sed writes to standard output unless you add the -i or --in-place option. Apr 29, 2021 at 20:50
  • Ok for -i, now background is ok, but i checked and with sudo find "/abc/abc/" -type f -exec sed -i "s/domain\it/domain\com/g" '{}' \; & nothing domain has been changed. Apr 30, 2021 at 14:51

1 Answer 1

0

Is /abc/abc/ an existing directory? Where are the files to be searched? The "paths must preceed.. " message is a crypto-mesage. Decoded it means that the first (or first several) parameter to find is not a directory tree for find to traverse. Since the rest of the parameters are "find expressions", that's what it complains about.

The command you're -execing needs to be terminated by a semicolon (;). But, since a semicolon would terminate (the parsing of) the find command, -exec's semicolon must be escaped with a backslash (\). thus

-exec ...command... \; Welcome to the world of `find` magic. Re-read `man find`.

Your sed expression is wrong. It should be:

 sed -e 's/domain1\.it/domain2\.com/'

The backslash (\) simply flips the "special handling" flag on the next character, so domain1\it matches "domain1it", not "domain1.it". "\i" isn't special, so it's treated like "i".

4
  • Comments are designed for US to ask YOU questions about your Question. You should Edit your question to add information. By updating your Question, and using the formatting buttons, you make all the information available to new readers. People shouldn't have to read a long series of comments to get the whole story.
    – waltinator
    Apr 30, 2021 at 14:43
  • Done, i added the second point in my Questions. Thanks. Apr 30, 2021 at 14:48
  • About your reply, i checked and with sudo find "/abc/abc/" -type f -exec sed -i "s/domain\it/domain\com/g" '{}' \; & nothing domain has been changed. Apr 30, 2021 at 14:50
  • Comments are designed for US to ask YOU questions about your Question. You should Edit your question to add information. By updating your Question, and using the formatting buttons, you make all the information available to new readers. People shouldn't have to read a long series of comments to get the whole story.
    – waltinator
    Apr 30, 2021 at 15:11

You must log in to answer this question.

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