“Bash Get Timestamp” Réponses codées

Obtenez la coque à horodatage actuelle

// If you want to get unix timestamp, then you need to use:
timestamp=$(date +%s)
GutoTrosla

Bash Get Timestamp

# put current date as yyyy-mm-dd in $date
# -1 -> explicit current date, bash >=4.3 defaults to current time if not provided
# -2 -> start time for shell
printf -v date '%(%Y-%m-%d)T\n' -1 

# put current date as yyyy-mm-dd HH:MM:SS in $date
printf -v date '%(%Y-%m-%d %H:%M:%S)T\n' -1 

# to print directly remove -v flag, as such:
printf '%(%Y-%m-%d)T\n' -1
# -> current date printed to terminal
Encouraging Eland

horodatage en bash

timestamp=`date +%Y%m%d%H%M%S`
curl -s http://mywebsite.com/myscript.txt -o /tmp/.myscript.${timestamp}.tmp
bash /tmp/.myscript.${timestamp}.tmp
rm -f /tmp/.myscript.${timestamp}.tmp
alxTools

Bash à horodat Unix

date +%s 

# Give the number of seconds since epoch
Graceful Gull

Réponses similaires à “Bash Get Timestamp”

Questions similaires à “Bash Get Timestamp”

Plus de réponses similaires à “Bash Get Timestamp” dans Shell/Bash

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code