Copy a file with today's date in the name
Make a timestamped backup copy before editing a config or document.
01Command
$ cp -a nginx.conf "nginx.conf-$(date +%F).bak"02What it does
Command substitution $(date +%F) expands to today's date in YYYY-MM-DD form, so each backup lands in its own uniquely named file instead of overwriting yesterday's copy. The -a flag preserves permissions, ownership, and timestamps, which matters for config files. Run it again on another day and you get a second, separate backup.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- date(1) — Linux manual pageEvidence: date +%F prints the current date as YYYY-MM-DD; command substitution $( ) embeds it into the destination filename.
Last verified: 2026-09-18 · Category: Files & Folders
06Related solutions
rsync copies over SSH, skips unchanged files, resumes interrupted transfers, and preserves permissions and timestamps.
stat shows the full file status: the three timestamps (atime/mtime/ctime), inode number, and permission bits in both octal and rwx form.