coreutils"stat"的POSIX类似物.命令? [英] POSIX analog of coreutils "stat" command?
本文介绍了coreutils"stat"的POSIX类似物.命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Coreutils stat
具有--format=
开关,以易于阅读的形式报告有关文件的不同信息(所有者,大小等).
Coreutils stat
have --format=
switch which report different info about file (owner, size, etc) in easy form for readers.
POSIX ls
实用程序提供了大多数此类信息,但是其输出很难解析.与单线比较:
POSIX ls
utility provide most of this info, but its output is hard to parse. Compare with one-liner:
[ `stat -c '%U' $f` = $USER ] && echo "You own $f" || echo Error!
POSIX中有stat
个实用程序模拟吗?
Are there stat
utility analog in POSIX?
推荐答案
简短的回答是否,POSIX没有提供简单的方法来获得与stat
相同的输出.但是,通常可以使用其他工具来获得相关的位.要特别地找到所有者:
The short answer is no, POSIX does not provide a simple way to get the same output as stat
. However, you can usually get relevant bits using other tools. To get the owner specifically:
ls -ld /path/of/file/or/directory | awk '{print $3}'
这篇关于coreutils"stat"的POSIX类似物.命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文