在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.下面的示例显示了数据库本身设置的所 ...
随机推荐
- JAVA 获取jdbc.properties配置信息
Properties myProperty = new Properties();String jdbcPath = PathKit.getWebRootPath()+File.separator+& ...
- [插头DP自我总结]
[HNOI 2007]神奇游乐园 #include <bits/stdc++.h> #define maxn 110 using namespace std; typedef long l ...
- Contest Hunter Round #70 - 连续两大交易事件杯省选模拟赛
orz lydrainbowcat [Problem A]「艦これ市」70万幕后交易事件 排序机器=-=.重要的是相同的处理. 我们可以从小到大添加数字,然后维护一个位置的序列.每一种相等的数字都在一 ...
- Idea_Maven配置
操作方式:在install上右键——>Run***install 出现Run Configurations ——>右键——>Edit Run Configuration 1.Inst ...
- Graph database_neo4j 底层存储结构分析(4)
3.3.2 DynamicStore 类型 3.3.2.1 AbstractDynamicStore 的存储格式 neo4j 中对于字符串等变长值的保存策略是用一组定长的 block ...
- Graph database_neo4j 底层存储结构分析(3)
3.3 通用的Store 类型 3.3.1 id 类型 下面是 neo4j db 中,每种Store都有自己的ID文件(即后缀.id 文件),它们的格式都是一样的. [test00]$ls - ...
- WebUI-自用
一.常用插件 1.弹出框架: http://layer.layui.com/ http://layer.layui.com/mobile/ 移动端 http://aui.github.io/artDi ...
- HDU 1394 Minimum Inversion Number(线段树/树状数组求逆序数)
Minimum Inversion Number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java ...
- NOJ 1643 阶乘除法(YY+小技巧)
[1643] 阶乘除法 时间限制: 5000 ms 内存限制: 65535 K 问题描述 输入两个正整数 n, m,输出 n!/m!,其中阶乘定义为 n!= 1*2*3*...*n (n>=1) ...
- HDU 1016 DFS
很简单的深搜 只要看出来是深搜... 注意判断最后一点是否与加一为质数 #include<stdio.h> #include<string.h> #include<alg ...