I have a script that uses sed
to search and replace a simple .yaml
file and output a .sh
file which should then be pulled in with source. My problem is that I can't figure out how to wait until sed
outputs the .sh
before calling source
.
sed -e 's/:[^:\/\/]/="/g;s/$/"/g;s/ *=/=/g' in.yaml > out.sh
source out.sh
EDIT
I get this error
script.sh: line 2: out.sh: No such file or directory
END EDIT
I've tried
sed -e 's/:[^:\/\/]/="/g;s/$/"/g;s/ *=/=/g' in.yaml > out.sh
wait $!
source out.sh
, but I believe that this requires the process to be in the bg. I tried throwing it in the bg, but I get the bg: no job control
error message. I read that overriding this is bad practice, so I'm trying to avoid doing so.
How can I make source
wait on sed
?
You don't have to do anything else than :
the shell by default run commands one by ones, so it will run
source
whensed
will finish.For your error, you should put the full path of
out.sh
in your source command.The
source
commands looks for the sourced file on your PATH when its name contains no slashes (but it only has to be readable; it does not have to be executable). You probably don't have the current directory on your PATH.Try: