Come faccio a elencare ogni altra estensione usando regex su Linux?


1

Ho il seguente comando che elenca tutti i file che hanno l'estensione .swf tuttavia mi piacerebbe restituire un elenco di tutti i file che non hanno l'estensione .swf

find . -maxdepth 1 -regextype posix-egrep -regex '.*/.*\.swf' -exec echo {} \;

Risposte:


3

Basta negare la condizione

-not -regex '.*/.*\.swf'

Funziona come un fascino. C'รจ comunque un modo solo usando le espressioni regolari?
PeanutsMonkey

Hmmm ... a -regex '. * /. * \. [^ s] [^ w] [^ f]' tipo di lavori, immagino.
tink

1

Se tutto quello che vuoi sono i file che non hanno il .swf estensione, basta usare il rovescio grep :

find . -maxdepth 1 -type f | grep -v *\.swf

O negare il -name con find:

find . -maxdepth 1 ! -name "*\.swf"
Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.