Useful Bash date Command

Most every time I write a shell script with bash, I need a date in there somewhere. And most every time, I need to read the man page to work out what the heck the format is I like. Now it’s documented here:

date ‘+%b_%d_%H%M’

This outputs as Name Of Month_Today’s Date_The 24 hour clock time right now.

It’s useful to enclose in backticks:

df -h | mail -s “The disk usage at: `date ‘+%b_%d_%H%M’`” jam@jamandbees.net

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s