#!/bin/bash
# catalog=( # 素組的格式是小括号:請将IP位址放置括号内,分隔符是換行或者空格
# 111
# 222
# )
# echo ${catalog[$1]} # 指定數組角标對應的元素;[$1] 角标數字(遊标卡尺): 指定第一個元素
# ${catalog} 數組:資料倉庫
# echo ${#catalog[*]} # 素組元素總個數
read -p "請輸入目錄:" catalog
# [ˈkætəlɔg]目錄
# catalog=/www/wwwroot/guzheng
filecatalog=(
$(ls $catalog)
)
quantity=${#filecatalog[*]} # [ˈkwɑn(t)ədi] 數量;kuan t ti
echo "目前目錄(數組)中檔案個數數量為:$quantity"
frequency=$quantity # [ˈfrikwənsi] 次數; fei ou kuan si
for((i=1;i<=$frequency; i++))
do
echo "正在依次列印該目錄的的檔案資訊: ${filecatalog[$i]} 檔案對應的角标為:$i"
done
read -p "請選擇角标進行删除複制修改移動操作:" cfile
operation=${filecatalog[$cfile]} # operation [ˌɑpəˈreɪʃ(ə)n] 操作
echo "您選擇的角标對應的檔案或目錄名稱為:" $operation
#sed -i "/^$/d" 1.sh ; chmod 755 1.sh ; ./1.sh