How to use the date / time variable in Bash?

Bash Liste Des Attaques Ovh

About

This page is about the management of time variable in Bash.

Example

Format in ISO 8601

Format Instant - String Format (ISO 8601)

date -u +"%Y-%m-%dT%H:%M:%SZ"

Date to file name

mv OPatch OPatch.bkp_$(date -u +"%Y-%m-%d.%H:%M")

# or
date -u +"%Y-%m-%d_%H.%M.%S"

Comparison

Conditional Double Bracket example

[[ $(date) =~ ^Fri\ ...\ 13 ]] && echo "It's Friday the 13th!"

Comparison

Name Double Bracket operator Single Bracket Operator
RegularExpression matching =~ (not available)





Discover More
Bash Liste Des Attaques Ovh
Bash - Conditional Expression

A predicate or boolean expression is known in Bash as a Conditional Expression. It is a command that returns an exit status of 0 or 1. The conditional expression is part of the compound expression. ...



Share this page:
Follow us:
Task Runner