Bash file attribute operators
Überprüft, ob es Datei gibt
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
Das Datum der Änderung zählt.
- file 1 -ot file 2
Das Datum der Änderung zählt.