在bash shell中使用getfattr查看文件扩展属性
getfattr用法
用于获取文件扩展属性,返回一系列键值对,参考Linux Man Page。
常用OPTIONS
-n name, --name=name
Dump the value of the named extended attribute extended attribute.
-d, --dump
Dump the values of all extended attributes associated with pathname.
-e en, --encoding=en
Encode values after retrieving them. Valid values of en are "text", "hex", and "base64". Values encoded as text strings are enclosed in double quotes ("), while strings encoded as hexidecimal and base64 are prefixed with 0x and 0s, respectively.
-h, --no-dereference
Do not dereference symlinks. Instead of the file a symlink refers to, the symlink itself is examined. Unless doing a logical (-L) traversal, do not traverse symlinks to directories.
-m pattern, --match=pattern
Only include attributes with names matching the regular expression pattern. The default value for pattern is "^user\\.", which includes all the attributes in the user namespace. Specify "-" for including all attributes. Refer to attr(5) for a more detailed discussion of namespaces.
--absolute-names
Do not strip leading slash characters ('/'). The default behaviour is to strip leading slash characters.
--only-values
Dump out the extended attribute value(s) only.
-R, --recursive
List the attributes of all files and directories recursively.
-L, --logical
Logical walk, follow symbolic links to directories. The default behaviour is to follow symbolic link arguments unless --no-dereference is given, and to skip symbolic links encountered in subdirectories. Only effective in combination with -R.
-P, --physical
Physical walk, do not follow symbolic links to directories. This also skips symbolic link arguments. Only effective in combination with -R.
--version
Print the version of getfattr and exit.
--help
Print help explaining the command line options.
使用举例
查看所有扩展属性的命令:
getfattr -m . -d -e hex --absolute-names $(vs_quick_lookup.sh vm-disk-1.qcow2 | grep $(hostname) | awk -F ":" '{print $2}')
结果:
# file: /sf/data/vs/local/V1gACv-8aPk-GDhe-nNnx-6uoD-isPj-ia9fSO/c93f1a03-ca0a-41cf-bca2-f723b35122ed/images/cluster/ljr.vm/vm-disk-1.qcow2
trusted.afr.vs_vol_rep2-client-10=0x000000000000000000000000
trusted.afr.vs_vol_rep2-client-11=0x000000000000000000000000
trusted.gfid=0x4751bfcc6ad6406d8e00a973d45a9d4e
user.glusterfs.bd=0x6c76323a313138353131333730323400
user.glusterfs.wcache=0x0000000000000000
选项说明:
-m . 匹配所有格式的扩展属性,默认的是user.xxx,即"^user\."。
-d -e hex 使用16进制编码dump出对应扩展属性的值
--absolute-names 不过滤路径分隔符('/')查看指定的扩展属性
getfattr -n 'trusted.gfid' -d -e hex --absolute-names $(vs_quick_lookup.sh vm-disk-1.qcow2 | grep $(hostname) | awk -F ":" '{print $2}' )
结果:
# file: /sf/data/vs/local/V1gACv-8aPk-GDhe-nNnx-6uoD-isPj-ia9fSO/c93f1a03-ca0a-41cf-bca2-f723b35122ed/images/cluster/ljr.vm/vm-disk-1.qcow2
trusted.gfid=0x4751bfcc6ad6406d8e00a973d45a9d4e
选项说明:
-n 指定扩展属性的名称
在bash shell中使用getfattr查看文件扩展属性的更多相关文章
- lsattr 查看文件扩展属性
1. 命令功能 lsattr查看 是否有chattr设置的权限. 2. 使用范例 [root@localhost data]# lsattr resolv.conf -----a-------e- r ...
- bash shell中测试命令
bash shell中测试命令 test命令提供了if-than语句中测试不同条件的途径.如果test命令中列出的条件成立,test命令就会退出并返回退出状态吗0 .这样if-than语句就与其他编程 ...
- Bash shell中的位置参数$#,$*,$@,$0,$1,$2...及特殊参数$?,$-等的含义
http://hi.baidu.com/lolorosa/blog/item/5775a608bd670d33b0351da7.html $# 是传给脚本的参数个数 $@ 是传给脚本的所有参数的列表 ...
- Bash Shell中Shift用法分享
这篇文章主要介绍了Bash Shell中Shift的使用方法,需要的朋友可以参考下 shift可以用来向左移动位置参数.Shell的名字 $0第一个参数 $1第二个参数 $2第n个参数 $n所有参数 ...
- Bash Shell中的特殊位置变量及其应用
Bash Shell中的特殊位置变量及其应用 众所周知bash shell中有许多特殊的位置变量,灵活使用它们可以更好地发挥Shell脚本的功用. 即位置变量:$1,$2,...来表示,用于让脚本在脚 ...
- 如何去掉drwxr-xr-x@中的@符号Linux文件扩展信息
如何去掉drwxr-xr-x@中的@符号Linux文件扩展信息ls -lart drwxrwxrwx@ 10 rlanffy staff 340B 3 6 2015 files-rwxrwxrwx@ ...
- PHP中DirectIO直操作文件扩展的使用
关于 PHP 的文件操作,我们也将是通过一系列的文章来进行学习.今天我们先学习的是一个很少人使用过,甚至很多人根本不知道的扩展,它与我们日常的文件操作有些许的不同.不过这些差别并不是我们肉眼所能直观看 ...
- linux中suid/sgid/sticky及扩展属性(attr)
suid只适用于命令文件.(如/usr/bin/passwd) 当命令文件上有suid权限时,则操作用户的权限变成属主权限.命令文件上无suid权限则操作用户的权限不变. 查看suid权限: [roo ...
- SQL Server -查看数据库扩展属性
1.fn_listextendedproperty 函数可以基于对象类型显示单个数据库对象或数据库中所有对象的扩展属性.例如,可以返回表或表中所有列的扩展属性. A.下面的示例显示了数据库本身设置的所 ...
随机推荐
- 【COGS & USACO Training】710. 命名那个数字(hash+水题+dfs)
http://cojs.tk/cogs/problem/problem.php?pid=710 近日开始刷水... 此题我为了练一下hash...但是hash跑得比暴力还慢.. 不言而喻... #in ...
- 【BZOJ】1877: [SDOI2009]晨跑(最小费用最大流)
http://www.lydsy.com/JudgeOnline/problem.php?id=1877 费用流做多了,此题就是一眼题. 拆点表示只能经过一次,容量为1,费用为0. 然后再连边即可,跑 ...
- 【Vijos】1431 守望者的逃离
题目链接:https://vijos.org/p/1431 算法:贪心 描述 恶魔猎手尤迪安野心勃勃,他背叛了暗夜精灵,率领深藏在海底的娜迦族企图叛变.守望者在与尤迪安的交锋中遭遇了围杀,被困在一个荒 ...
- NOI2011阿狸的打字机(fail树+DFS序)
Description 阿狸喜欢收藏各种稀奇古怪的东西,最近他淘到一台老式的打字机.打字机上只有28个按键,分别印有26个小写英文字母和'B'.'P'两个字母. 经阿狸研究发现,这个打字机是这样工作的 ...
- kernel里面出现了类似isegfault at xxx ip 错误
今天同时碰到了错误如下,但是没有core,当时通过代码审查解决了问题,后续再查的时候发现可以使用addr2line 查找代码行, segfault at 10000 ip b7f0f48a sp bf ...
- 【C语言】08-数组
为了让大家更好地学习和理解数组,我们先来认识一下内存中的"地址". 地址 1.计算机中的内存是以字节为单位的存储空间.内存的每一个字节都有一个唯一的编号,这个编号就称为地址.凡存放 ...
- 发现未知字段 state ,过滤条件 [["state","not in",["draft"]]] 有误 的处理
通常该问题出现的原因在于对象定义的state字段在view中并没有出现,解决方案就是在view中添加该字段即可.
- 关于SparkMLlib的基础数据结构 Spark-MLlib-Basics
此部分主要关于MLlib的基础数据结构 1.本地向量 MLlib的本地向量主要分为两种,DenseVector和SparseVector,顾名思义,前者是用来保存稠密向量,后者是用来保存稀疏向量,其创 ...
- Ubuntu基础命令
显示历史命令的时间戳 echo 'HISTTIMEFORMAT="%F %T "' >> ~/.bashrc 解压文件/打包文件夹 tar -zxvf folder ...
- Export-XLSX PowerShell generate real Excel XLSX files without Excel and COM
http://gallery.technet.microsoft.com/scriptcenter/Export-XLSX-PowerShell-f2f0c035