Paul Paul - 1 month ago 5
Bash Question

Find shell script and rename row

I have shell script with name script.sh. I need to find this script and change value inside script

From:

bash $current_dir/run.sh


to

./run.sh.x


my solution is something like:

find -maxdepth 10 -name "script.sh" -exec sed -i 's#bash '$current_dir'#run.sh#.#runs.sh.x#' {} \ ;


But still my command does not work. Any idea how to replace this string in new string in my shell script?

Answer

Your sed expression seems to be the issue.

You can use:

find . -maxdepth 10 -name "script.sh" -exec sed -i 's#bash \$current_dir/run\.sh#./run.sh.x#' {} +