A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 9 Ω
Das Banner der Rhetos-Website: zwei griechische Denker betrachten ein physikalisches Universum um sie herum.

Bash file attribute operators

Überprüft, ob es Datei gibt

© 2016 - 2025




Basiswissen


In der Programmiersprache Bash kann man bestimmte vom System belegte Eigenschaften von Dateien auslesen. Dazu stehen hier einige Beispiele.

Beispiel


Beispiel: if [ -a test ]; then cat test; fi
Falls es die Datei test gibt, zeige ihren Inhalt an.

Alle Operatoren


  • a file exists
  • d file exists and is a directory
  • e file exists; same as -a
  • f file exists and is a regular file (i. e. not a directory)
  • r you have read permission on file
  • s file exists and is not empty
  • w you have write permission on file
  • x you have execute permission on file
  • x you have directory search permission
  • N file was modified since it was last read
  • O you own file
  • G file's group ID matches yours

Weitere Beispiele


  • file 1 -nt file2
File is newer than file 2
Das Datum der Änderung zählt.

  • file 1 -ot file 2
File 1 is older than file 2
Das Datum der Änderung zählt.