Sounds like a homework...?
Anyway, does it have to be printed just when typing «
date », with no arguments?
If so, you'll have to write a function called « date » too in your
.bashrc file, in which you'll check whether
there are arguments, and if not, print the string «
Today is:<blank> » followed by
the output of the
date command. (
hint: the keyword
command)
If there are arguments, then simply run
date(1) with the arguments provided.
----
Solution:Code:
date() { ((! $#)) && printf '%s %s\n' 'Today is:' "$(command date)" || command date "$@"; }
----
Understanding:
In order:
I invite you to follow the full
BashGuide.
----
P.S.: Wooledge >> TLDP.