Files
tldr/pages.fa/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
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# [
> بررسی نوع فایل و مقایسه مقدار ها
> عدد 0 برمیگرداند اگر شرط درست باشد و 1 اگر شرط نادرست باشد
> اطلاعات بیشتر: <https://www.gnu.org/software/bash/manual/bash.html#index-test>.
- بررسی میکند که آیا یک متغییر با رشته معین برابر است یا نابرابر :
`[ "${{متغییر}}" {{=|!=}} "{{رشته}}" ]`
- اینکه متغییری برابر/ نابرابر/ بزرگتر از/ کوچکتر از/ برابر یا بزرگتر/ کوچکتر یا برابر با عددی است را بررسی میکند :
`[ "${{متغییر}}" -{{eq|ne|gt|lt|ge|le}} {{عدد_صحیح}} ]`
- اینکه متغییر با مقدار معین دارد یا مقدار نا معین دارد را بررسی میکند :
`[ -n "${{متغییر}}" ]`
- اینکه متغییری مقدار تهی دارد را بررسی میکند :
`[ -z "${{متغییر}}" ]`
- اینکه فایل معینی وجود دارد یا خیر را بررسی میکند :
`[ -f {{مسیر/به/فایل}} ]`
- اینکه دایرکتوری معینی وجود دارد یا خیر را بررسی میکند :
`[ -d {{مسیر/به/پوشه}} ]`
- اینکه فایل یا دایرکتوری معینی وجود دارد یا خیر را بررسی میکند :
`[ -e {{مسیر/به/فایل_یا_پوشه}} ]`