0

I have a script which creates another script when run like this:

cat > "$installpath""tweets.sh" << ENDOFFILE
#!/bin/bash
source "$installpath"config.sh
cd \$webdir
/usr/local/bin/twint -s "\$search" --limit \$scrapelimit -o \$csvname --csv --database \$dbfile -ho
FILE=\$csvname
NAME=\${FILE%.*}
EXT=\${FILE#*.}
DATE=`\date +%d-%m-%Y-%H-%M`
NEWFILE=\${NAME}_\${DATE}.\${EXT}
echo \$NEWFILE
mv \$csvname \$NEWFILE
export NEWFILE
export DATE
ENDOFFILE

However, the script interprets the

DATE=`\date +%d-%m-%Y-%H-%M`

and changes it to

DATE=28-09-2019-15-49

I have tried escaping the variables in every possible way but nothing seems to work. Any ideas?

Cyrus
  • 84,225
  • 14
  • 89
  • 153
Niclas
  • 89
  • 9

1 Answers1

0

I suggest to use:

DATE=\$(date +%d-%m-%Y-%H-%M)
Cyrus
  • 84,225
  • 14
  • 89
  • 153