I was afraid of that. If you think you need to generate a script to do something shell can't do, you're probably missing a few important things. Last time, it was a fellow who wanted to generate script0001.sh-script9999.sh to work on file0001 through file9999, because he didn't know how to use loops and commandline parameters...
Why not make a script that just does what you want in the first place? What feature are you missing which would allow you to do so?
Actually I am trying to write a shell script for android phones...so the script was supposed to generate another script in the init.d folder so that it will run on boot...the main script can only be run manually...
One thing about looping...I tried to use while loops with nested if...but I got "while" unmatched errors all the time...checked the parameters and they are correct, and if I remove the nested ifs, then it will loop...weird...
Thanks.
Another discover I find, is the use of - before EOF .
It suppress tabs and spaces in front of line to be show on output. Makes programming more struktured.
$ name='JOTNE'
$ cat <<EOF
> Name is $name
> EOF
Name is JOTNE
$ cat <<-EOF
> Name is $name
> EOF
Name is JOTNE