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 指定扩展属性的名称

linux getfattr中文乱码,在bash shell中使用getfattr查看文件扩展属性相关推荐

  1. linux bash and,linux bash shell中for的用法and示例

    关于linux bash shell中的for语句 在linux中shell是必不可少的一部分,但是在bash shell中有while,for,until等循环命令,今天就介绍一下关于for的一些用 ...

  2. win10复制粘贴linux,如何在Windows 10的Bash Shell中启用复制和粘贴键盘快捷键 | MOS86...

    Windows 10s Bash shell终于有了方便的复制和粘贴键盘快捷键,但是出于兼容性原因,默认情况下将它们禁用. 这些快捷方式在2018年10月更新中可用,该更新最初代号为Redstone ...

  3. 教你解决ChartDirector Linux下中文乱码

    用ChartDirector这个c++库画图的时候会遇到乱码的问题. 在同事的指导下,将所有的中文先转换成utf8编码. 然后用simsun.ttc这个字体显示. 就ok了. 今天又遇到了这个问题,还 ...

  4. oracle用中文linux,linux+oracle中文乱码

    一 linux显示中文乱码 : 首先在终端输入locale察看目前Linux用的是什么语言 然后输入:LANG= zh_CN.utf8看看系统是否可以支持中文 输入date测试一下可以看到有许多乱码, ...

  5. JFreeChart 生成图表 在linux服务器中文乱码问题

    JFreeChart 生成图表 在linux服务器中文乱码问题 java中用JfreeChart可以生成图表,而不借助于flash,js,canvas等技术: 图表中的文字生成依赖于系统本地字体,但在 ...

  6. Linux oracle中文乱码的问题解决

    Linux oracle中文乱码的问题解决 参考文章: (1)Linux oracle中文乱码的问题解决 (2)https://www.cnblogs.com/leolzi/p/9796316.htm ...

  7. Bash Shell中16进制数字和ASCII字符相互转换

    Bash Shell中ASCII值和字符之间的转换 1.数值转换为ASCII字符 方法一: i=97echo $i | awk '{printf("%c", $1)}' 方法二: ...

  8. linux oracle 中文乱码解决方案

    linux oracle 中文乱码解决方案 su - oracle cd /home/oracle 1.查看客户端编码 env |grep LANG 2.修改客户端编码 vi .bash_profil ...

  9. Windows系统中通过命令查看文件的MD5,SHA1,SHA256校验值

    Windows系统中通过命令查看文件的MD5,SHA1,SHA256校验值 命令格式如下: certutil -hashfile yourfilename MD5 certutil -hashfile ...

最新文章

  1. 鸿蒙程序如何上传,鸿蒙应用程序流转的实现
  2. 加密ASP为DLL的详细步骤给点RMB不多是个心意尊重脑力劳动者的付出
  3. 【Verilog HDL 训练】第 01 天
  4. Linux下的ELF可执行文件学习总结
  5. dw1000 配置无法通过
  6. 喜大普奔!Github 移动端上架!
  7. 两个服务之间的调用请求
  8. centOS 7下安装与配置heartbeat高可用集群
  9. 总结替换jar包中指定文件的步骤
  10. 多项式拟合缺点_拟合多项式的最小二乘法
  11. Integer与int的区别
  12. vsftpd虚拟用户整理
  13. Android编程之ActivityManager: Segmentation fault
  14. JavaScript内置对象导读(1)
  15. 芝加哥计算机科学硕士录取难度,美国cs研究生申请难度有多大?
  16. 【大结局】三体 III 中的思想实验:死神永生(下)
  17. Oracle12c CDB和PDB数据库的启动与关闭说明
  18. 2019年全国大学生电子设计竞赛赛题分享与浅析
  19. dbm与mysql_关于dBm与功率转换
  20. android 4.4.2 安全漏洞修复

热门文章

  1. 将ejs转为html,Node.js Express Web应用框架ejs修改为html
  2. Spring Boot中自带的这些工具类,你用过几个?
  3. 前瞻:Spring 6.0将停止支持Freemarker和JSP
  4. 战争升级!Elasticsearch 从客户端向 AWS 开了一炮!
  5. 这样统计代码执行耗时,才足够优雅!
  6. 每日一皮:学会说话很重要...
  7. 每日一皮:一个难以复现的 bug ...
  8. Spring Boot 2.x基础教程:使用集中式缓存Redis
  9. java restful项目打包_听说你在接私活? 一个助你效率翻倍的项目工具!!
  10. 电脑html按键侧滑广告,HTML5侧滑聊天面板