mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-09-10 17:33:38 +02:00

* [: use posix-compliant example for equals comparison the previous example worked fine for bash, but some other shells (zsh, in my case) will not work when using "==" for comparison. the posix spec only requires "=", so I think it makes a little more sense to use that in the example. * test: use posix-compliant example for equals comparison the previous example worked fine for bash, but some other shells (zsh, in my case) will not work when using "==" for comparison. the posix spec only requires "=", so I think it makes a little more sense to use that in the example.
922 B
922 B
[
Controleer bestandstypes en vergelijk waardes. Geeft een 0 terug als de voorwaarde waar (true) is, als het niet waar (false) is geeft het een 1 terug. Meer informatie: https://www.gnu.org/software/bash/manual/bash.html#index-test.
- Test of een gegeven variabele gelijk is aan een gegeven tekst:
[ "${{variable}}" {{=|!=}} "{{string}}" ]
- Test of een gegeven variabele gelijk/niet gelijk/groter dan/kleiner dan/groter dan of gelijk/kleiner dan of gelijk aan het gegeven nummer:
[ "${{variable}}" -{{eq|ne|gt|lt|ge|le}} {{integer}} ]
- Test of een gegeven variabele een niet-lege waarde heeft:
[ -n "${{variable}}" ]
- Test of een gegeven variable een lege waarde heeft:
[ -z "${{variable}}" ]
- Test of een bestand bestaat:
[ -f {{pad/naar/bestand}} ]
- Test of een map bestaat:
[ -d {{pad/naar/map}} ]
- Test of een bestand of een map bestaat:
[ -e {{pad/naar/bestand_of_map}} ]