⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 showperm.bash

📁 UNIX下SH的实现源码
💻 BASH
字号:
#Newsgroups: comp.unix.shell#From: gwc@root.co.uk (Geoff Clare)#Subject: Re: Determining permissions on a file#Message-ID: <Dr79nw.DtL@root.co.uk>#Date: Fri, 10 May 1996 17:23:56 GMT#Here's a bit of Korn shell that converts the symbolic permissions produced#by "ls -l" into octal, using only shell builtins.  How to create a script#combining this with an "ls -l" is left as an exercise...### Converted to Bash v2 syntax by Chet Ramey <chet@po.cwru.edu>## usage: showperm modestring## example: showperm '-rwsr-x--x'#[ -z "$1" ] && {	echo "showperm: usage: showperm modestring" >&2	exit 2}tmode="$1"typeset -i omode sbitstypeset pmode# check for set-uid, etc. bitssbits=0case $tmode in???[sS]*)       (( sbits += 8#4000 )) ;; # set-uid??????[sSl]*)   (( sbits += 8#2000 )) ;; # set-gid or mand. lock?????????[tT]*) (( sbits += 8#1000 )) ;; # stickyesacomode=0while :do	tmode=${tmode#?}	case $tmode in	"")       break ;;	[-STl]*)  (( omode *= 2 )) ;;	[rwxst]*) (( omode = omode*2 + 1 )) ;;	*)	  echo "$0: first letter of \"$tmode\" is unrecognized" >&2	          (( omode *= 2 ))	          ;;	esacdone(( omode += sbits ))printf "0%o\n" $omode

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -