Article 5HCHD [bash] re-use script for variation

[bash] re-use script for variation

by
tvc457
from LinuxQuestions.org on (#5HCHD)
I'm having a simple issue with this Bash-script I have, and I can't come up with an elegant solution for it.

So, I have a script, which is working and all, no problem.
Now, I need to run a similar thing now, the difference is: some parts of the code don't need to be run for this variation. Obviously I'm not copying the script, and just removing the unneeded lines, because the rest of the code will be duplicate code - and that is a no-go.

Lets say my initial script (script1.sh) is this:

#!/bin/bash

<code section A>
<code section B>
<code section C>
<code section D>
<code section E>
<code section F>
<code section G>
<code section H>
<code section I>

But for this variation, I just want to run :

<code section A>
<code section B>
<code section D>
<code section F>
<code section G>
<code section I>

I could use IF statements, either for the sections of code I want to run, or the other way round, but I feel that solution is not very nice. If it was just one section being different, it would be an option, but it's repeating through the whole script.latest?d=yIl2AUoC8zA latest?i=BVpt13C857c:KivQfgcp1vk:F7zBnMy latest?i=BVpt13C857c:KivQfgcp1vk:V_sGLiP latest?d=qj6IDK7rITs latest?i=BVpt13C857c:KivQfgcp1vk:gIN9vFwBVpt13C857c
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments