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

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/u014711094/article/details/88072878

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

猜你喜欢

转载自blog.csdn.net/u014711094/article/details/88072878
今日推荐