Adding Date Stamp To File Name With sed

trying to add a date stamp to the name of a file with sed. can't seem to comment out the date command so that sed does not only see it as a literal text string

this is what I'm trying

ls file.txt | sed 's/file.txt/file\/`date`\/.txt/g'

but it's giving this

file/`date`/.txt

looking for something like

file20170406.txt

any ideas would be appreciated

What operating system and shell are you using?

For standard shells, command substitutions are not performed inside single-quoted strings. And, if they were, the sed substitute command you're using would produce output similar to:

file/Thu Apr  6 12:06:36 PDT 2017/.txt

not:

file20170406.txt

Why are you performing a global substitution when there can never be more than one match?

What are you trying to accomplish? Using ls and sed won't rename a file. If you want to rename files, there are much more efficient ways of coming up with the new names without invoking external utilities (other than date and mv ).

If you're not trying to rename files, what is the purpose of this exercise?