Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux 程式設計 >> Shell 程式設計

Shell 中將十進制轉為十六進制的方法

在 Shell 中,若要把十進制數字轉成十六進制,可使用 printf 的格式輸出。

printf "%x" 123
printf "%X" 100

若要把字符串的 ASCII 內容轉成十六進制,可使用 od 命令,例如:

echo "helloworld" | od -tx1

printf 適合數字格式轉換,od 則適合查看字符的位元組表示。

Copyright © Linux教程網 All Rights Reserved