2001-07-10 14:25:50 +00:00
|
|
|
#!/bin/bash
|
2001-09-04 13:27:31 +00:00
|
|
|
# Exercising the 'date' command
|
2001-07-10 14:25:50 +00:00
|
|
|
|
|
|
|
echo "The number of days since the year's beginning is `date +%j`."
|
2001-09-04 13:27:31 +00:00
|
|
|
# Needs a leading '+' to invoke formatting.
|
2001-07-10 14:25:50 +00:00
|
|
|
# %j gives day of year.
|
|
|
|
|
|
|
|
echo "The number of seconds elapsed since 01/01/1970 is `date +%s`."
|
2001-10-15 14:21:41 +00:00
|
|
|
# %s yields number of seconds since "UNIX epoch" began,
|
|
|
|
#+ but how is this useful?
|
2001-07-10 14:25:50 +00:00
|
|
|
|
|
|
|
prefix=temp
|
2004-01-26 00:03:37 +00:00
|
|
|
suffix=$(date +%s) # The "+%s" option to 'date' is GNU-specific.
|
2001-07-10 14:25:50 +00:00
|
|
|
filename=$prefix.$suffix
|
2008-11-23 22:43:47 +00:00
|
|
|
echo "Temporary filename = $filename"
|
|
|
|
# It's great for creating "unique and random" temp filenames,
|
2001-10-15 14:21:41 +00:00
|
|
|
#+ even better than using $$.
|
2001-07-10 14:25:50 +00:00
|
|
|
|
|
|
|
# Read the 'date' man page for more formatting options.
|
|
|
|
|
|
|
|
exit 0
|