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

📄 bash-hexdump.sh

📁 android-w.song.android.widget
💻 SH
字号:
#From: "dennis" <dennis@netstrata.com>#To: <bash-maintainers@gnu.org>#Subject: New example script: bash-hexdump#Date: Mon, 4 Jan 2010 22:48:19 -0700#Message-ID: <6dbec42d$64fcdbd2$4a32cf2d$@com>#I've written a script that functions like "hexdump -C" or "hd". If you'd #like to include it in a future distribution of example Bash scripts, I have #included it here: #!/bin/bash# bash-hexdump# pure Bash, no externals# by Dennis Williamson - 2010-01-04# in response to http://stackoverflow.com/questions/2003803/show-hexadecimal-numbers-of-a-file# usage: bash-hexdump filesaveIFS="$IFS"IFS=""                     # disables interpretation of \t, \n and spacesaveLANG="$LANG"LANG=C                     # allows characters > 0x7Fbytecount=0valcount=0printf "%08x  " $bytecountwhile read  -d '' -r -n 1 char    # -d '' allows newlines, -r allows \do   ((bytecount++))   # for information about the apostrophe in this printf command, see   #  http://www.opengroup.org/onlinepubs/009695399/utilities/printf.html   printf -v val "%02x" "'$char"   echo -n "$val "   ((valcount++))   if [[ "$val" < 20 || "$val" > 7e ]]   then       string+="."                  # show unprintable characters as a dot   else       string+=$char   fi   if (( bytecount % 8 == 0 ))      # add a space down the middle   then       echo -n " "   fi   if (( bytecount % 16 == 0 ))   # print 16 values per line   then       echo "|$string|"       string=''       valcount=0       printf "%08x  " $bytecount   fidone < "$1"if [[ "$string" != "" ]]            # if the last line wasn't full, pad it outthen   length=${#string}   if (( length > 7 ))   then       ((length--))   fi   (( length += (16 - valcount) * 3 + 4))   printf "%${length}s\n" "|$string|"   printf "%08x  " $bytecountfiechoLANG="$saveLANG";IFS="$saveIFS"exit 0

⌨️ 快捷键说明

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