我想以特定格式获取文件的修改时间。
我怎样才能做到这一点 ?
我知道
stat -c %x find.txt
Run Code Online (Sandbox Code Playgroud)
但我需要这种格式:
yyyymmddhh24miss
Run Code Online (Sandbox Code Playgroud)
我使用ksh的Linux 2.6.18-406.el5 x86_64,如果它很重要。
我想在我的 unix shell /usr/bin/ksh 中执行 stat 命令:
输入:
/bin/date +%Y%m%d%H%M%S -d "$(/usr/bin/stat -c %x find.txt)"
Run Code Online (Sandbox Code Playgroud)
和输出:
/usr/bin/ksh: stat: not found
Run Code Online (Sandbox Code Playgroud)
我的系统: SunOS 5.10 Generic_150400-23 sun4v sparc sun4v
我需要在不解压缩的情况下删除 gz 文件的最后一行。该文件有 500 行。
我怎样才能做到这一点?
我试过了:
gzip -dc "$files" | tail -500 | gzip -c > "$files".tmp
Run Code Online (Sandbox Code Playgroud)
但它不起作用。