免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1364 | 回复: 4
打印 上一主题 下一主题

请教shell的一个问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-05-03 16:58 |只看该作者 |倒序浏览
( /usr/sbin/sshd -\? 2>&1 | grep -q OpenSSH ) 2>/dev/null || exit 0

if [ "$(stat -c %d/%i /)" = "$(stat -Lc %d/%i /proc/1/root 2>/dev/null)" ];
这两条分别是什么意思?

第一条中间的那个-\?以及第二条中的%d%i /具体是什么作用?

希望有高手能指导一下。不甚感激!

论坛徽章:
8
摩羯座
日期:2014-11-26 18:59:452015亚冠之浦和红钻
日期:2015-06-23 19:10:532015亚冠之西悉尼流浪者
日期:2015-08-21 08:40:5815-16赛季CBA联赛之山东
日期:2016-01-31 18:25:0515-16赛季CBA联赛之四川
日期:2016-02-16 16:08:30程序设计版块每日发帖之星
日期:2016-06-29 06:20:002017金鸡报晓
日期:2017-01-10 15:19:5615-16赛季CBA联赛之佛山
日期:2017-02-27 20:41:19
2 [报告]
发表于 2012-05-03 17:22 |只看该作者

  1. The valid format sequences for files (without --file-system):

  2. %a
  3.     Access rights in octal
  4. %A
  5.     Access rights in human readable form
  6. %b
  7.     Number of blocks allocated (see %B)
  8. %B
  9.     The size in bytes of each block reported by %b
  10. %C
  11.     SELinux security context string
  12. %d
  13.     Device number in decimal
  14. %D
  15.     Device number in hex
  16. %f
  17.     Raw mode in hex
  18. %F
  19.     File type
  20. %g
  21.     Group ID of owner
  22. %G
  23.     Group name of owner
  24. %h
  25.     Number of hard links
  26. %i
  27.     Inode number
  28. %n
  29.     File name
  30. %N
  31.     Quoted file name with dereference if symbolic link
  32. %o
  33.     I/O block size
  34. %s
  35.     Total size, in bytes
  36. %t
  37.     Major device type in hex
  38. %T
  39.     Minor device type in hex
  40. %u
  41.     User ID of owner
  42. %U
  43.     User name of owner
  44. %x
  45.     Time of last access
  46. %X
  47.     Time of last access as seconds since Epoch
  48. %y
  49.     Time of last modification
  50. %Y
  51.     Time of last modification as seconds since Epoch
  52. %z
  53.     Time of last change
  54. %Z
  55.     Time of last change as seconds since Epoch

  56. Valid format sequences for file systems:

  57. %a
  58.     Free blocks available to non-superuser
  59. %b
  60.     Total data blocks in file system
  61. %c
  62.     Total file nodes in file system
  63. %d
  64.     Free file nodes in file system
  65. %f
  66.     Free blocks in file system
  67. %C
  68.     SELinux security context string
  69. %i
  70.     File System ID in hex
  71. %l
  72.     Maximum length of filenames
  73. %n
  74.     File name
  75. %s
  76.     Block size (for faster transfers)
  77. %S
  78.     Fundamental block size (for block counts)
  79. %t
  80.     Type in hex
  81. %T
  82.     Type in human readable form

  83. NOTE: your shell may have its own version of stat, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports.
复制代码

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
3 [报告]
发表于 2012-05-04 11:34 |只看该作者
前面的这个
  1. /usr/sbin/sshd -\? 2>&1
复制代码
很怪异,从来没有看过这种方式的命令选项。
后面那个
  1. $(stat -c %d/%i /)
复制代码
指定输出信息的格式,输出包含/目录的文件系统信息。

论坛徽章:
0
4 [报告]
发表于 2012-05-04 17:09 |只看该作者
回复 3# L_kernel
这个是Ubuntu下面ssh的一个启动脚本。


   

论坛徽章:
0
5 [报告]
发表于 2012-05-05 18:59 |只看该作者
本帖最后由 iblicf 于 2012-05-05 19:09 编辑

第一个就是个转义符号而已,,,sshd -? |grep -q OpenSSH

( /usr/sbin/sshd -\? 2>&1 | grep -q OpenSSH ) 2>/dev/null || exit 0 如果不是 OpenSSH 就退出
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP