在 Ubuntu 中,你可以使用多种命令来获取当前的时间戳。以下是几种常用的方法:
使用 date
命令:
date +%s
date +%s%3N
或者date +%s | xargs -I {} echo "{}$(printf '%03d' $(date +%N | cut -b1-3))"
使用 perl
命令:
perl -MTime::HiRes -e 'print time(), "\n"'
perl -MTime::HiRes -e 'printf "%.0f\n", Time::HiRes::time() * 1000'
使用 python
命令:
python -c 'import time; print(int(time.time()))'
python -c 'import time; print(int(time.time() * 1000))'
这些命令都可以在终端中直接运行,根据你的需求选择合适的方法即可。