Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
bashでstrftimeを使用してナノ秒でUnix Timeを取得する方法はありますか?
UNIX時間の私の行:
<command> | awk '{ print strftime("%s"), $0; }'
date は 1 回しか評価されないため、date +%N は使用できません。
回避策はありますか?
while read を使用して回避策を見つけました。日付はそのように更新されます。strftime は必要ありません。
<command> | while read line; do d=`date +%s%N`; echo $d $line; done
あなたはまだ使うことができますdate
date
ls | xargs -IQ date "+%s.%N Q"
出力に%を含めないでください...(ただし、これを回避することもできます)