My bash script writes an another bash script using printf.
printf \"#!/bin/bash
HOME=${server}
file=gromacs*
file_name=\\$(basename \"\\${file}\")
date=\\$(date
You have to escapes in printf
with esscaps, e. g.:
date=\$(date +"%%m_%%d_%%Y")
should print date=\$(date +"%m_%d_%Y")
. But you should avoid using printf
, because you don't use it's capabilities. Instead you could cat the string to the file:
cat > ${output}/collecter.sh <<'END'
HOME=${server}
...
done
END
This would allow you to avoid many escapes, and make the code more readable.