shell腳本 for循環(huán)實現(xiàn)文件和目錄遍歷
[root@localhost HeZuoShi_wt]# cat read_dir.sh #!/bin/bash #print the directory and file for file in /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/*; do if [ -d "$file" ]; then echo "$file is directory"; elif [ -f "$file" ]; then echo "$file is file"; fi; done [root@localhost HeZuoShi_wt]# ./read_dir.sh /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/EPSG_4326_01 is directory /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/EPSG_4326_02 is directory /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/EPSG_4326_03 is directory /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/EPSG_4326_04 is directory /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/EPSG_4326_05 is directory /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/EPSG_4326_06 is directory /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/EPSG_4326_07 is directory /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/EPSG_4326_08 is directory /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/EPSG_4326_09 is directory /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/EPSG_4326_10 is directory /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/EPSG_4326_11 is directory /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/EPSG_4326_12 is directory /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/EPSG_4326_13 is directory /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/EPSG_4326_14 is directory /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/EPSG_4326_15 is directory /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/EPSG_4326_16 is directory /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/EPSG_4326_17 is directory /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/EPSG_4326_18 is directory /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/read_dir.sh is file /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/衛(wèi)圖_中國_9至11級_4326瓦片.rar is file /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/衛(wèi)圖_全球_1至8級_無邊界_4326瓦片.rar is file /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/衛(wèi)圖_合作市_15至17級_4326瓦片.zip is file /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/衛(wèi)圖_合作市_主城區(qū)_框選_18級_4326瓦片.zip is file /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/衛(wèi)圖_甘南藏族自治州_11至14級_4326瓦片.zip is file /disk2/oyz3dserver/oyz_HeZuoShi/geoserver/HeZuoShi_wt/衛(wèi)圖_甘肅省_12至13級_4326瓦片.rar is file [root@localhost HeZuoShi_wt]#
本文摘自 :https://www.cnblogs.com/