在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.下面的示例显示了数据库本身设置的所 ...
随机推荐
- 百度搜索词&淘宝搜索词 接口实现
百度和淘宝并没有正式的提供一个公开API给我们用,但是经过分析他们的源代码,还是找到了解决方法. 1 2 3 4 5 6 7 8 9 /*baidu&taobao callback*/ fun ...
- topcoder SRM 593 DIV2 WolfDelaymaster
#include <iostream> #include <string> #include <algorithm> using namespace std; cl ...
- [Cocos2d-x For WP8]Particle粒子系统
在游戏中,经常要实现一些真实的效果,这些效果(如,火焰,雪花等)都是由大量微粒组合而形成的.为了在游戏中实现这种效果,我们必须引进粒子系统,粒子系统中需要包括四个部分:粒子对象,运动规律,随机性,粒子 ...
- BZOJ4129: Haruna’s Breakfast
Description Haruna每天都会给提督做早餐! 这天她发现早饭的食材被调皮的 Shimakaze放到了一棵 树上,每个结点都有一样食材,Shimakaze要考验一下她. 每个食材都有一个美 ...
- Java Web网站应用中的单点登录
采用SSH架构加以说明:1. 建立一个登录管理类LoginManager2. 在LoginManager中定义一个集合,管理登录的用户.3. 在Spring中将LoginManager配置成单例 ...
- JavaScript - 时间函数
时间美化函数 /* 1.< 60s, 显示为“刚刚” 2.>= 1min && < 60 min, 显示与当前时间差“XX分钟前” 3.>= 60min &am ...
- 自制Chrome拓展
淘宝试用自动点击: 谷歌其实就是一些html+css+js+静态资源.但是里面有一个特别的配置文件manifest.json.该文件和Android的那个androidmanifest.xml类似,记 ...
- graph | Max flow
最大流算法,解决的是从一个起点到一个终点,通过任何条路径能够得到的最大流量. 有个Edmond-Karp算法: 1. BFS找到一条增广路径:算出这条路径的最小流量(所有边的最小值)increase: ...
- explicit关键字
C++中,explicit关键字用来修饰类只有一个参数的构造函数,被修饰的构造函数的类,不能发生相应的隐式类型转换,只能以显示的方式进行类型转换. explicit使用注意事项: explicit 关 ...
- Nginx 笔记与总结(16)nginx 负载均衡
nginx 反向代理时,如果后端有多台服务器,就可以实现负载均衡. 实现原理:把多台服务器用 upstream 绑定在一起并起一个组名,然后 proxy_pass 指向该组. ngx_http_ups ...