Bash replacing content INLINE using a WGET and CAT commands

Viewed 73

I am working on some kind of version control for a specific software (Bash script.) When a new version releases, the code should be updated to the latest release, I have figured this out but I seem stuck and can't make the replacement inline.

#First we download the source code with wget, it returns a text with the new code
wget www.example.com/sourcecode | cat . > $0

How can I redirect that output (text / script) to the current script who's executing it and replace it. Note $0 gives us the location of the current script. So the cat command, just should replace the new text coming from wget to the current script.

Thanks!

1 Answers

Your question is a bit confused, so I can try to guess your needs.

Are you asking how to capture the output of the commmand you posted?

If yes, the solution is:

source_file_content=$(wget -O - http://www.example.com/sourcecode)

# Do anything with ${source_file_content}

Let me know if it is right for you.

Related