命令替换命令替换是指 shell 可以先执行命令,将输出结果暂时保存,在适当的地方输出。命令替换的语法:command注意这是反引号,而不是单引号,这个键位于 ESC 键的下方。案例:\#!/bin/bashDATE=`date`echo "Date is $DATE" \USERS=`who | wc -l`echo "Logged in user are $USERS"UP=`date ;
函数案例一:\#!/bin/bashhello () { echo "hahahah"}hello执行函数,结果为:hahaha案例二:\#!/bin/bashfunWithReturn(){ echo "the function is to get the sum of two number" read -p "input first number" num1 read -p "input second number" num2 echo "the two number are $num1 and $num2 !