Comando del terminale Mac: come "ls" per alcuni file specifici?

3

La mia domanda riguarda il comando ls. Se ho troppi file in una cartella, potrei aver bisogno di:

  1. ls file solo con un determinato tipo o;

  2. ls file all'interno di un intervallo, ovvero file con nomi da * a b *.

posta Jun 16.10.2013 - 05:52
fonte

1 risposta

12
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
    
risposta data 16.10.2013 - 06:54
fonte

Leggi altre domande sui tag