Trovare file con nome differente da pattern

Per trovare tutti i file in una data directory con nome differente da un certo pattern usare il seguente comando: find . -not -name *.txt L’esempio cercherà nella directory corrente, ed in tutte le sottodirectory, tutti i file che non terminano con *.txt

Estrarre un numero da una stringa

$ NUMERO=$(echo “Ho 999 anni.” | tr -dc ‘0-9’) $ echo $NUMERO. 999. $ NUMBER=$(echo “Ho 999 anni.” | sed ‘s/[^0-9]*//g’) $ echo $NUMERO. 999. $ STRING=”Ho 999 anni.” $ echo “${STRING//[!0-9]/}” 999. O. $ echo “${STRING//[^0-9]/}” $ NUMERO=$(echo “Ho 999 anni.” | grep -o -E ‘[0-9]+’) $ echo $NUMERO. 999.