Types de fichiers d’un serveur Web

$ sudo nano /usr/local/bin/wwwsearch
#!/bin/bash

RED='\033[0;31m'
NC='\033[0m'
DIR="/var/www/mysite/"

EXTENSIONSET=(
		"HTML		htm.?" \
		"CSS		css"  \
		"JS		js"  \
		"PHP		php.?"  \
		"TWIG		twig"  \
		"Python		py"  \
		"Perl		pl"  \
		"CGI		cgi"  \
		"Ruby		rb"  \
		"XHTML		xhtml"  \
		"XML		xml"  \
		"YAML		(yml|yaml)"  \
		"TOML		toml"  \
		"JSON		json"  \
		"C#		cs"  \
		"Java		java"  \
		"JSP		jsp"  \
		"ASP		asp.?"  \
		"VB		vb"  \
		"Flash		swf"  \
		"AS		as"  \
		"MD		(md|markdown)"  \
		"TXT		txt"  \
)

if [ ! -d "${DIR}" ]; then
	echo "Le répertoire cible n'existe pas..."
	exit 1
fi

search() {

		result=$(find "${DIR}" -type f -regextype posix-extended -iregex ".*\.${2}" | wc -l)
		printf "%-10s ${RED}%12s${NC}\n" "${1}" "${result}"
}

echo "-----------------------"

for EXT in "${EXTENSIONSET[@]}"
do
	search ${EXT}
done

echo "-----------------------"
$ sudo wwwsearch
-----------------------
HTML                 97
CSS                 164
JS                  785
PHP               13132
TWIG                560
Python                5
Perl                  0
CGI                   0
Ruby                  0
XHTML                 0
XML                1215
YAML                555
TOML                  0
JSON               1220
C#                   10
Java                  1
JSP                   0
ASP                   0
VB                    0
Flash                 1
AS                    0
MD                   32
TXT                 425
-----------------------

Fermer le menu