lundi 1 mai 2017

UNIX - Negate (if statement)

I have logs files that I would like to see that have not been compress yet (gzip) I have this and it works but it checks if the files end in .gz.

#!/bin/bash

LOG_FILES=(
   "/Sandbox/logs/*"
)


for file in ${LOG_FILES[@]}; do
   if [[ $file =~ \.gz$ ]]; then
      echo $file
   fi
done

How do I display the files that do not end in .gz?

I tried

![ $file =~ \.gz$ ]
!( $file =~ \.gz$ )

but I get a syntax error. Any suggestions?

Aucun commentaire:

Enregistrer un commentaire