自動統計檔案型別指令碼
# !/bin/bash # 檔名: filestat.sh if [ $# -ne 1 ]; then echo "Usage is $0 basepath"; exit fi path=$1 declare -A statarray; while read line; do ftype=`file -b "$line" | cut -d, -f1` let statarray["$ftype"]++; done < <(find $path -type f -print) echo ============ File types and counts ============= for ftype in "${!statarray[@]}"; do echo $ftype : ${statarray["$ftype"]} done
執行結果:
相關推薦
自動統計檔案型別指令碼
# !/bin/bash # 檔名: filestat.sh if [ $# -ne 1 ]; then echo "Usage is $0 basepath"; exit fi path=$1 declare -A statarray; while
File類的檔案型別數量統計
需求: /* * 輸入一個資料夾路徑 用map記錄檔案型別出現的次數 * * txt 數量 * java 數量 * png 數量 * .... */ import java.io.File; import java.util.Comparat
nginx實現自動切割日誌檔案shell指令碼
在工作中可能會需要對nginx的日誌實現自動分割,自己寫了一個函式,大家如果覺得可以的話: 可以直接複製儲存修改一下nginxPATH和 /opt/nginx/sbin/nginx -s reopen這兩個地方 地址。然後直接使用。 #!/bin/bash #引數解釋:$1 切割日誌的
linux自動備份檔案 並上傳到遠端伺服器 指令碼實現
(1)在伺服器上建立備份目錄,並賦予許可權 mkdir -p /backup/bakdata #新建資料備份目錄 (2)完成備份指令碼操作 新建指令碼檔案 vi bakdata.sh 新增以下內容: #!/bin/sh dateTime=`dat
Linux Shell 指令碼自動建立檔案並修改其許可權
在學習《Linux命令列與shell指令碼程式設計大全》第三版時,每次執行書上的程式碼時,需要建立一個testxx.sh檔案,修改其執行許可權,最後再用vim來編輯。這樣一個重複的過程,可以通過書中學習的知識編寫一個指令碼來自動解決,該指令碼命名為NewTest
使用shell指令碼統計檔案中ip出現的次數
首先準備檔案demo.txt,內容如下: 1 192.168.41.20 2 192.168.41.21 3 192.168.41.22 4 192.168.41.23 5 192.168.41.24 6 192.168.41.25 統
用Python指令碼獲取指定路徑下的指定檔案型別的檔名並儲存至指定檔案
import os def getIMGname(dir, ftrain, ftest, num): filenames = sorted(os.listdir(dir)) i = 0 for filename in filenames:
Linux啟動和關閉時自動執行的所有指令碼檔案
原文地址:http://www.cnblogs.com/armlinux/archive/2010/08/11/2390949.html Linux使用的是基於執行級(run-levels)概念的稱為SysVinit的專用啟動工具。SysVinit(從現在開始我
shell指令碼統計檔案中單詞的個數
一、方案 http://www.cnblogs.com/youxuguang/p/5917215.html 方法一: (1)cat file|sed 's/[,.:;/!?]/ /g'|awk '{for(i=1;i<=NF;i++)array[$i]++;}END{for(i in array)
shell指令碼實現自動生成檔案頭資訊用到的語法
/******************************************************** *Author: Goup * *Date: 2017-08-29 14:15 * *Description: cat >> "$1" <&l
(BUG)Kettle8.1.0.0-365轉換步驟輸出SQL檔案insert指令碼日期型別資料,格式不正確且沒有雙引號
浪費了“黃金五年”的Java程式設計師,還有救嗎? >>>
Linux使用Shell指令碼實現FTP自動下載檔案,並記錄下載檔案日誌
Linux使用Shell指令碼實現FTP自動下載檔案,並記錄下載檔案日誌 最近初學shell程式設計,記一下自己寫的第一個指令
PLSQL 打開時出現"動態執行表不可訪問,本會話的自動統計被禁止"
訪問權限 app 對話 導航 如果 name 局限 方式 點擊 這個報錯信息在不同的PL/SQL Developer版本都會出現,從上面詳細的報錯提示信息中我們可以判斷得到,報錯原因不在工具本身。在此,詳細記錄一下這個小問題的三種處理方法。1.第一種處理方法(不推薦)就是在
inno 區分win7 win8 win8.1 win10 x64 x86不同系統,安裝不同驅動檔案的指令碼編寫
完整inno指令碼下載連結 https://download.csdn.net/download/wangxingxing321/10392692 一、為了簡化教程,我們使用inno打包的exe檔案是最簡單的HelloWorld.exe,如下圖
NS2 trace檔案分析指令碼(適合無線trace)
絡上有不少awk程式是講如何分析網路效能的(主要是時延,吞吐量,丟包率和時延抖動),但是都沒有詳細的說明,我在此作一些示例,添加了一些必要的說明註釋。 以下的內容是針對NS2模擬的結果trace檔案進行網路效能分析,看本篇前需要先行了解的的內容有:awk語言的基礎,包括語法和結構等;在Linux下
刪除重複檔案的指令碼程式碼
測試環境 :centos7 ⚠️注意:該程式碼在Mac os系統下會因為引數問題報錯 無引數“ls --time-style” "uniq -w" "md5sum" mac 安裝md5命令 brew install md5sha1sum #!/bin/bash #查詢並刪除重複檔案 每
pssh批量管理伺服器 pssh執行本地檔案(指令碼)
pssh命令是一個python編寫可以在多臺伺服器上執行命令的工具,同時支援拷貝檔案,是同類工具中很出色的,類似pdsh,個人認為相對pdsh更為簡便,使用必須在各個伺服器上配置好金鑰認證訪問。 1. 安裝 安裝可以使用yum或者apt-get安裝,還可以使用原始碼安裝, 由於我使用a
FATFS 檔案管理 (1) - 判斷檔案型別
思路:通過判斷檔案字尾來判斷檔案型別; (1) 先建立基準資料 TODO: update the count #define FILE_MAX_MAIN_TYPE 7 #define FILE_MAX_SUB_TYPE 4 static const char *File_
極光推送在鑰匙串中證書匯出無法選擇P12檔案型別
今天在整合極光推送SDK的時候,按照這篇文章進行了app id和開發,釋出證書的建立之後,發現將開發和釋出證書新增到系統鑰匙串之後匯出時無法選擇p12檔案,這樣就沒辦法上傳到鐳射的推送配置去,於是把app id,證書刪了重建,還是不行,不過在期間出現過一次可以匯出p12檔案的情況,不過不記得怎麼操作
如何利用winrar製作自解壓,自動執行檔案格式的壓縮包
操作提前:電腦安裝WinRAR軟體。 將用來製作的資料放在資料夾內,然後用Ctrl+A全選該資料夾下的檔案。 單擊滑鼠右鍵,然後選擇“新增到壓縮檔案”選項。 在開啟的對話方塊“常規”選項卡中,單擊“壓縮方式”下拉框選擇合適的壓縮方式,並將壓縮選項下的“建立自解壓格式壓縮檔案”選項勾選,這時候會發現“