I'm trying to read a txt file which has new lines, for example this:
#!/usr/bin/env sh
# Hi, this is a txt file that I will make a printf
# and I will execute later
VARIABLE_A=%s
VARIABLE_B=%s
VARIABLE_C=%s
so, this is my file txt_script.sh
and what I'm trying to do, is:
- Making my own bash script.
- Read
txt_script.sh
in a variable as text. - Use printf to change those
%s
- Write it in a new file.
My code is:
#!/bin/bash
create_script=`cat model_files/txt_script.sh`
create_script=`printf "$create_script" $1 $2 $3`
echo -e $create_script > model_files/create_imagenet_generated.sh
but my final txt file gets this format:
(If I execute ./my_bash_script.sh aAa bBb cCc
)
#!/usr/bin/env sh # Hi, this is a txt file that I will make a printf # and I will execute later VARIABLE_A=aAa VARIABLE_B=bBb VARIABLE_C=cCc
How can I make it readable to be able to execute as bash script? like that, is everything a comment.
Thank you in advance.
Rafael.