Files
tldr/pages.nl/common/[.md
Gabe Livengood 9d865abee1 test: Use POSIX-compliant example for equals comparison (#11728)
* [: 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.
2023-12-14 20:31:13 +05:30

34 lines
922 B
Markdown

# [
> 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}} ]`