一、在檔案中搜尋關鍵詞的命令是( D)。react
一、在檔案中搜尋關鍵詞的命令是( D)。react
A、ps B,eat C、more D、grepshell
二、查看⽂件最後100⾏的命令是( )。編程
tail -n 100bash
三、實現查詢⽂件fifile1⾥⾯空格開始的所在的⾏號?測試
grep -n "^$" fifile1spa
四、統計/etc/fstab⽂件中每一個單詞出現的次數?code
grep -E "\<[[:alpha:]]+\>" /etc/fstab -o | sort | uniq -cblog
五、如何查看fifile1⽂件的第300到500⾏的內容?ip
cat fifile1 | head -n 500 | tail -n 300 自動化
六、shell 腳本編程的主要應用範圍有哪些?
①自動化經常使用命令 ② 執行系統管理和故障排除
③ 建立簡單的應用程序 ④處理文本或文件
七、 shell 腳本文件的第一行中 #!/bin/bash 的做用是什麼?
聲明屬於哪一種shell
八、編寫腳本 hostping.sh,接受一個主機的 IPv4 地址作爲參數,測試是否可連通。若是能 ping 通,則提示用戶「該IP地址可訪問」;若是不可 ping 通,則提示用戶「該IP地址不可訪問」。
#!/bin/bash # #******************************************************************** #Author: yindesheng #QQ: 941268778 #Date: 2020-06-07 #FileName: hostping.sh #URL: http://192.168.24.66 #Description: The test script #Copyright (C): 2020 All rights reserved #******************************************************************** read -p "請輸入一個主機的 IPv4 地址: " IP ping $IP -c3 &> /dev/null if [ $? -eq 0 ];then echo "該IP地址可訪問" else echo "該IP地址不可訪問" fi