I'm writing a bash script in FreeBSD that appends commands to a log file. Before I execute the commands that will append the log data, I want to print a line in the file which shows the current date above the data, like this:
---Tue Aug 20 17:26:37 EDT 2019---
I know that I can use the date command to output the timestamp, but I'm not sure how to include the "---" before and after the timestamp to add to the file. What's the simplest way to do this?
printf '-- %s --' "$(date)"orprintf '-- '; date | tr -d \\n; printf ' --'date | sed -e 's/^/-- /' -e 's/$/ --/'datesupports it:date +'-- %a %b %d %T %Z --'%FT%T.