La mia domanda riguarda il comando ls. Se ho troppi file in una cartella, potrei aver bisogno di:
-
ls file solo con un determinato tipo o;
-
ls file all'interno di un intervallo, ovvero file con nomi da * a b *.
ls *.jpg # files whose name ends with .jpg
ls [ab]* # files whose name starts with a or b
ls [a-c]* # files whose name starts with characters sorted between a and c in the current locale
ls|head -n100 # first 100 files
f=(*);printf %s\n "${f[@]:0:100}" # first 100 files
ls|sed -n 101,200p # files 101 to 200
find . -name \*aa\* # files whose name contains aa in the directory tree
find . ! -type d # all files except directories in the directory tree
find . -type f -maxdepth 1 -mindepth 1 # regular files in the current directory
shopt -s extglob;printf %s\n !(*aa*) # files whose name does not contain aa
shopt -s extglob;printf %s\n @(aa|bb)* # files whose name starts with aa or bb