I need to create the dump file name with the current date as postfix to the file name in shell script.
I tried below command in my script but that did not work.
Can any one suggest me the way :
... dump_'$(date '+%Y-%m-%d')'.txt
BACKGROUND:
I feel Its not require to mention details about the script as it is not completely related to the question but still I want to give some information.
My script is copying some lines from other *txt
files and creating a separate dump.txt
file .But I want to mention date as a postfix to the dump filename to understand the history about the file.
#!/bin/bash
# summary script
echo "Summary!"
shopt -s extglob
for f in */data/*txt; do tail -n+5 $f | head -1 | tr -d "\n"; echo " $f |"; done > dump.txt
sed -nE '/[[:blank:]][[:digit:]]?[[:digit:]]%/P' dump.txt > dump_$(date '+%Y-%m-%d').txt
wc -l dump_'$(date '+%Y-%m-%d')'.txt
You just need to remove de quotes that prevents shell interpretation:
dump_$(date '+%Y-%m-%d').txt