婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > shell中函數(shù)的應用

shell中函數(shù)的應用

熱門標簽:外呼電話系統(tǒng)怎么操作 天津電話外呼系統(tǒng)排名 商機地圖標注 測繪地圖標注名稱 德陽400電話申請 百度地圖標注直線距離 怎么在百度地圖標注公司的位置 鶴崗400電話申請 智能電銷機器人有用嗎

To turn the functions in this chapter into a library for use in other scripts, extract all the functions and concatenate them into one big file. If we call this file library.sh, a test script that accesses all of the functions might look like this:

#!/bin/sh

# Library test script
. library.sh
initializeANSI

echon "First off, do you have echo in your path? (1=yes, 2=no) "
read answer
while ! validint $answer 1 2 ; do
 echon "${boldon}Try again${boldoff}. Do you have echo "
 echon "in your path? (1=yes, 2=no) "
 read answer
done

if ! checkForCmdInPath "echo" ; then
 echo "Nope, can't find the echo command."
else
 echo "The echo command is in the PATH."
fi

echo ""
echon "Enter a year you think might be a leap year: "
read year

while ! validint $year 1 9999 ; do
 echon "Please enter a year in the ${boldon}correct${boldoff} format: "
 read year
done

if isLeapYear $year ; then
 echo "${greenf}You're right! $year was a leap year.${reset}"
else
 echo "${redf}Nope, that's not a leap year.${reset}"
fi

exit 0

應用函數(shù),我們就可以復用我們的腳本。

值得注意的是 $ . tinyscript.sh ,就是在當前shell下執(zhí)行腳本,不加"."或source

則會在子shell下執(zhí)行腳本,可能會有不同的情況發(fā)生,值得注意。

您可能感興趣的文章:
  • Shell中關于時間和日期的函數(shù)總結
  • Linux 在Shell腳本中使用函數(shù)實例詳解
  • shell 使用數(shù)組作為函數(shù)參數(shù)的方法(詳解)
  • Shell使用Epoch進行日期時間轉換和計算的幾個小函數(shù)
  • Linux Shell函數(shù)返回值
  • PowerShell中的函數(shù)重載示例
  • Shell中函數(shù)返回值超出問題
  • Shell函數(shù)的7種用法介紹
  • Shell腳本中使用function(函數(shù))示例
  • 淺談Shell中的函數(shù)

標簽:自貢 武漢 六盤水 鎮(zhèn)江 百色 優(yōu)質小號 滁州 丹東

巨人網(wǎng)絡通訊聲明:本文標題《shell中函數(shù)的應用》,本文關鍵詞  shell,中,函數(shù),的,應用,shell,;如發(fā)現(xiàn)本文內容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《shell中函數(shù)的應用》相關的同類信息!
  • 本頁收集關于shell中函數(shù)的應用的相關信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 河东区| 巨野县| 麟游县| 墨脱县| 平湖市| 南木林县| 芜湖县| 岫岩| 嘉兴市| 东宁县| 集安市| 鄂托克前旗| 吉林省| 滕州市| 涪陵区| 老河口市| 定州市| 蕲春县| 莱阳市| 临江市| 平远县| 遂昌县| 宣汉县| 无锡市| 大兴区| 鹿邑县| 韩城市| 本溪| 马尔康县| 衡山县| 宜州市| 偃师市| 德格县| 上杭县| 德江县| 土默特左旗| 永修县| 那曲县| 阜南县| 澄城县| 云梦县|