I'm working on a portable anaconda package, and I'm trying to use find and sed to find all files and replace a path within the files within the current directory and its subdirectories.

When I execute the command, however, sed throws the error:

sed: couldn't edit anaconda3: not a regular file

The command I'm using is:

find ./ -type f -exec sed -i -e "s+/opt/conda_tools+$TOOLKIT_DIR+g" * {} \;

I'm using + as the delimiter since the / are part of the path. The contents of the directory I'm executing the script in is:

drwxr-xr-x 24 test_user linuxusers 4096 Nov 21 16:07 anaconda3

Executing the find command on its own lists the files as expected, but for some reason the directory name is being picked up still. I've also tried the following variation of the command with no success:

find ./ -type f -exec sed -i '' "s+/opt/conda_tools+$INSTALL_DIR+g" * {} \;

I've used find and sed successfully before, but I'm a bit stumped where to look next. Is there anything that obviously wrong that I'm missing here, or not so obvious?

1 Answer 1


Remove the '*' from

find ./ -type f -exec sed -ie "s+/opt/conda_tools+$TOOLKIT_DIR+g" * {} \;


find ./ -type f -exec sed -ie "s+/opt/conda_tools+$TOOLKIT_DIR+g" {} \;
  • you have -i ''. I think you want -ie 'repl string' Nov 21, 2017 at 17:09
  • Absolutely correct, thanks for pointing that out!
    – Glenak1911
    Nov 21, 2017 at 17:30

You must log in to answer this question.

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