Results 1 to 2 of 2
I need to write a script with nested EOF's to avoid generating potentially very large numbers of intermediate files and cannot work out how to do this, rough code follows; ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 03-09-2011 #1
- Join Date
- Mar 2011
bash nested EOF
I need to write a script with nested EOF's to avoid generating potentially very large numbers of intermediate files and cannot work out how to do this, rough code follows; any ideas greatly appreciated
start of inner_script contents
end of inner_script contents
- 03-10-2011 #2
- Join Date
- Nov 2008
- Tokyo, Japan
First, my opinion is, if you need nested "Here Files", you are almost certainly going about solving your problem the wrong way. Or if you are sure this is the ONLY way to solve the problem, you are better of NOT using bash. Try Perl or Python instead.
However, to answer your question, I would do it like thisCode:
#!/bin/bash cat <<-__SUB_COMMAND0__ Executed within level 0 __SUB_COMMAND0__ bash <<-__LEVEL1__ cat <<-__SUB_COMMAND1__ Executed within level 1 __SUB_COMMAND1__ bash <<-__LEVEL2__ cat <<-__SUB_COMMAND2__ Executed within level 2 __SUB_COMMAND2__ __LEVEL2__ __LEVEL1__
However, as you can see, this quickly turns into spaghetti code and is very difficult to read and debug.