linux文件属性查看和编辑,ls、stat、file、touch命令

ls

# -l指示列出文件详细属性
# -h指示文件大小显示K M G等格式,-si指示文件大小显示为KB MB GB格式
# -r指示反向排序,默认按照文件名称排序
ls -l --humanreadable --reverse
# 同上,简写
ls -lhr

# -1指示list one file per line.
# -R  --recursive	指示列出子目录中的文件
# -i  --inode		打印文件索引号(index number)
ls -1 -R -i

# 按时间、大小、扩展名、自然排序
ls --sort=time --sort=size --sort=extension --sort=none
ls -t -S -X -U

stat

stat one.txt

# 参数的解释
atime	--	access	--	the time of last access
mtime	--	modify	--	the time of last data modifition
ctime	--	change	--	the time of last status change
birth	--	the time of file birth

file

file *
# one.txt: ASCII text, with CRLF line teminators
# two.txt: UTF-8 text, with CRLF line teminators
# mydir: directory
# some.zip: Zip archive data, at least v2.0 to extract

touch

# windows下修改atime, mtime,则ctime会自动更新为当前时间
# 将文件atime和mtime改为当前时间,one.txt不存在则创建
touch one.txt

# -a指示atime/access time,-m指示mtime/modify time
# -r指示参考(--reference)two.txt的时间
touch -a -r two.txt one.txt

# 修改one.txt的atime为2019-002 11:32:30
touch --time=atime -t 201903021132.30 one.txt

# 修改one.txt的mtime为2019-03-02 11:32:30
touch -m -d "2019-0-302 11:32:30" one.txt
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值