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

📄 ex47.sh

📁 Shall高级编程
💻 SH
字号:
#!/bin/bash# printf demoPI=3.14159265358979DecimalConstant=31373Message1="Greetings,"Message2="Earthling."echoprintf "Pi to 2 decimal places = %1.2f" $PIechoprintf "Pi to 9 decimal places = %1.9f" $PI  # It even rounds off correctly.printf "\n"                                  # Prints a line feed,                                             # Equivalent to 'echo' . . .printf "Constant = \t%d\n" $DecimalConstant  # Inserts tab (\t).printf "%s %s \n" $Message1 $Message2echo# ==========================================## Simulation of C function, sprintf().# Loading a variable with a formatted string.echo Pi12=$(printf "%1.12f" $PI)echo "Pi to 12 decimal places = $Pi12"      # Roundoff error!Msg=`printf "%s %s \n" $Message1 $Message2`echo $Msg; echo $Msg#  As it happens, the 'sprintf' function can now be accessed#+ as a loadable module to Bash,#+ but this is not portable.exit 0

⌨️ 快捷键说明

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