查看文件时间戳命令:stat awk.txt
File: `awk.txt'
Size: 20 Blocks: 8 IO Block: 4096 regular file
Device: 801h/2049d Inode: 380730 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2008-04-26 01:50:44.000000000 +0800
Modify: 2008-04-26 01:48:18.000000000 +0800
Change: 2008-04-26 01:48:18.000000000 +0800
现在是要过滤出Modify的时间戳,并以yyyyMMddHHSS格式保存,则可以利用下面这条命令:
stat awk.txt | grep -i Modify | awk -F. '{print $1}' | awk '{print $2$3}'| awk -F- '{print $1$2$3}' | awk -F: '{print $1$2$3}'
输出结果:20080426014818