Get Current Timestamp in Shell
In a shell script, you can use the date command to retrieve the current timestamp. Here is an example code:
#!/bin/bash
# 获取当前时间戳
timestamp=$(date +%s)
echo "当前时间戳为:$timestamp"
In this example, $(date +%s) is the command used to retrieve the current timestamp. Running this script will display the current timestamp.