{
    "content": [
        {
            "type": "text",
            "text": "# test (man)\n\n## NAME\n\ntest - check file types and compare values\n\n## SYNOPSIS\n\ntest EXPRESSION\n\n## DESCRIPTION\n\nExit with the status determined by EXPRESSION.\n\n## TLDR\n\n> Check file types and compare values.\n\n- Test if a given variable is equal to a given string:\n  `test \"{{$MY_VAR}}\" = \"{{/bin/zsh}}\"`\n- Test if a given variable is empty ([z]ero length):\n  `test -z \"{{$GIT_BRANCH}}\"`\n- Test if a [f]ile exists:\n  `test -f \"{{path/to/file}}\"`\n- Test if a [d]irectory does not exist:\n  `test ! -d \"{{path/to/directory}}\"`\n- If A is true, then do B, or C in the case of an error (notice that C may run even if A fails):\n  `test {{condition}} && {{echo \"true\"}} || {{echo \"false\"}}`\n- Use `test` in a conditional statement:\n  `if test -f \"{{path/to/file}}\"; then echo \"File exists\"; else echo \"File does not exist\"; fi`\n\n*Source: tldr-pages*\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS** (2 subsections)\n- **DESCRIPTION** (23 subsections)\n- **AUTHOR**\n- **REPORTING BUGS**\n- **COPYRIGHT**\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "test",
        "section": "",
        "mode": "man",
        "summary": "test - check file types and compare values",
        "synopsis": "test EXPRESSION",
        "tldr_summary": "Check file types and compare values.",
        "tldr_examples": [
            {
                "description": "Test if a given variable is equal to a given string",
                "command": "test \"{{$MY_VAR}}\" = \"{{/bin/zsh}}\""
            },
            {
                "description": "Test if a given variable is empty ([z]ero length)",
                "command": "test -z \"{{$GIT_BRANCH}}\""
            },
            {
                "description": "Test if a [f]ile exists",
                "command": "test -f \"{{path/to/file}}\""
            },
            {
                "description": "Test if a [d]irectory does not exist",
                "command": "test ! -d \"{{path/to/directory}}\""
            },
            {
                "description": "If A is true, then do B, or C in the case of an error (notice that C may run even if A fails)",
                "command": "test {{condition}} && {{echo \"true\"}} || {{echo \"false\"}}"
            },
            {
                "description": "Use `test` in a conditional statement",
                "command": "if test -f \"{{path/to/file}}\"; then echo \"File exists\"; else echo \"File does not exist\"; fi"
            }
        ],
        "tldr_source": "official",
        "flags": [
            {
                "flag": "",
                "long": "--version",
                "arg": null,
                "description": "output version information and exit An omitted EXPRESSION defaults to false. Otherwise, EXPRESSION is true or false and sets exit status. It is one of: ( EXPRESSION ) EXPRESSION is true ! EXPRESSION EXPRESSION is false EXPRESSION1 -a EXPRESSION2 both EXPRESSION1 and EXPRESSION2 are true EXPRESSION1 -o EXPRESSION2 either EXPRESSION1 or EXPRESSION2 is true"
            },
            {
                "flag": "-n",
                "long": null,
                "arg": null,
                "description": "the length of STRING is nonzero STRING equivalent to -n STRING"
            },
            {
                "flag": "-z",
                "long": null,
                "arg": null,
                "description": "the length of STRING is zero STRING1 = STRING2 the strings are equal STRING1 != STRING2 the strings are not equal INTEGER1 -eq INTEGER2 INTEGER1 is equal to INTEGER2 INTEGER1 -ge INTEGER2 INTEGER1 is greater than or equal to INTEGER2 INTEGER1 -gt INTEGER2 INTEGER1 is greater than INTEGER2 INTEGER1 -le INTEGER2 INTEGER1 is less than or equal to INTEGER2 INTEGER1 -lt INTEGER2 INTEGER1 is less than INTEGER2 INTEGER1 -ne INTEGER2 INTEGER1 is not equal to INTEGER2 FILE1 -ef FILE2 FILE1 and FILE2 have the same device and inode numbers FILE1 -nt FILE2 FILE1 is newer (modification date) than FILE2 FILE1 -ot FILE2 FILE1 is older than FILE2"
            },
            {
                "flag": "-b",
                "long": null,
                "arg": null,
                "description": "FILE exists and is block special"
            },
            {
                "flag": "-c",
                "long": null,
                "arg": null,
                "description": "FILE exists and is character special"
            },
            {
                "flag": "-d",
                "long": null,
                "arg": null,
                "description": "FILE exists and is a directory"
            },
            {
                "flag": "-e",
                "long": null,
                "arg": null,
                "description": "FILE exists"
            },
            {
                "flag": "-f",
                "long": null,
                "arg": null,
                "description": "FILE exists and is a regular file"
            },
            {
                "flag": "-g",
                "long": null,
                "arg": null,
                "description": "FILE exists and is set-group-ID"
            },
            {
                "flag": "-G",
                "long": null,
                "arg": null,
                "description": "FILE exists and is owned by the effective group ID"
            },
            {
                "flag": "-h",
                "long": null,
                "arg": null,
                "description": "FILE exists and is a symbolic link (same as -L)"
            },
            {
                "flag": "-k",
                "long": null,
                "arg": null,
                "description": "FILE exists and has its sticky bit set"
            },
            {
                "flag": "-L",
                "long": null,
                "arg": null,
                "description": "FILE exists and is a symbolic link (same as -h)"
            },
            {
                "flag": "-N",
                "long": null,
                "arg": null,
                "description": "FILE exists and has been modified since it was last read"
            },
            {
                "flag": "-O",
                "long": null,
                "arg": null,
                "description": "FILE exists and is owned by the effective user ID"
            },
            {
                "flag": "-p",
                "long": null,
                "arg": null,
                "description": "FILE exists and is a named pipe"
            },
            {
                "flag": "-r",
                "long": null,
                "arg": null,
                "description": "FILE exists and the user has read access"
            },
            {
                "flag": "-s",
                "long": null,
                "arg": null,
                "description": "FILE exists and has a size greater than zero"
            },
            {
                "flag": "-S",
                "long": null,
                "arg": null,
                "description": "FILE exists and is a socket"
            },
            {
                "flag": "-t",
                "long": null,
                "arg": null,
                "description": ""
            },
            {
                "flag": "-u",
                "long": null,
                "arg": null,
                "description": "FILE exists and its set-user-ID bit is set"
            },
            {
                "flag": "-w",
                "long": null,
                "arg": null,
                "description": "FILE exists and the user has write access"
            },
            {
                "flag": "-x",
                "long": null,
                "arg": null,
                "description": "FILE exists and the user has execute (or search) access Except for -h and -L, all FILE-related tests dereference symbolic links. Beware that paren‐ theses need to be escaped (e.g., by backslashes) for shells. INTEGER may also be -l STRING, which evaluates to the length of STRING. NOTE: Binary -a and -o are inherently ambiguous. Use 'test EXPR1 && test EXPR2' or 'test EXPR1 || test EXPR2' instead. NOTE: [ honors the --help and --version options, but test does not. test treats each of those as it treats any other nonempty STRING. NOTE: your shell may have its own version of test and/or [, which usually supersedes the ver‐ sion described here. Please refer to your shell's documentation for details about the op‐ tions it supports."
            }
        ],
        "examples": [],
        "see_also": [
            {
                "name": "access",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/access/2/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "test",
                        "lines": 1
                    },
                    {
                        "name": "[ ]",
                        "lines": 2
                    }
                ]
            },
            {
                "name": "DESCRIPTION",
                "lines": 4,
                "subsections": [
                    {
                        "name": "--version",
                        "lines": 17,
                        "long": "--version"
                    },
                    {
                        "name": "-n",
                        "lines": 4,
                        "flag": "-n"
                    },
                    {
                        "name": "-z",
                        "lines": 35,
                        "flag": "-z"
                    },
                    {
                        "name": "-b",
                        "lines": 2,
                        "flag": "-b"
                    },
                    {
                        "name": "-c",
                        "lines": 2,
                        "flag": "-c"
                    },
                    {
                        "name": "-d",
                        "lines": 2,
                        "flag": "-d"
                    },
                    {
                        "name": "-e",
                        "lines": 2,
                        "flag": "-e"
                    },
                    {
                        "name": "-f",
                        "lines": 2,
                        "flag": "-f"
                    },
                    {
                        "name": "-g",
                        "lines": 2,
                        "flag": "-g"
                    },
                    {
                        "name": "-G",
                        "lines": 2,
                        "flag": "-G"
                    },
                    {
                        "name": "-h",
                        "lines": 2,
                        "flag": "-h"
                    },
                    {
                        "name": "-k",
                        "lines": 2,
                        "flag": "-k"
                    },
                    {
                        "name": "-L",
                        "lines": 2,
                        "flag": "-L"
                    },
                    {
                        "name": "-N",
                        "lines": 2,
                        "flag": "-N"
                    },
                    {
                        "name": "-O",
                        "lines": 2,
                        "flag": "-O"
                    },
                    {
                        "name": "-p",
                        "lines": 2,
                        "flag": "-p"
                    },
                    {
                        "name": "-r",
                        "lines": 2,
                        "flag": "-r"
                    },
                    {
                        "name": "-s",
                        "lines": 2,
                        "flag": "-s"
                    },
                    {
                        "name": "-S",
                        "lines": 2,
                        "flag": "-S"
                    },
                    {
                        "name": "-t",
                        "lines": 1,
                        "flag": "-t"
                    },
                    {
                        "name": "-u",
                        "lines": 2,
                        "flag": "-u"
                    },
                    {
                        "name": "-w",
                        "lines": 2,
                        "flag": "-w"
                    },
                    {
                        "name": "-x",
                        "lines": 16,
                        "flag": "-x"
                    }
                ]
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "REPORTING BUGS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 6,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "test - check file types and compare values\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "test EXPRESSION",
                "subsections": [
                    {
                        "name": "test",
                        "content": "[ EXPRESSION ]"
                    },
                    {
                        "name": "[ ]",
                        "content": "[ OPTION\n"
                    }
                ]
            },
            "DESCRIPTION": {
                "content": "Exit with the status determined by EXPRESSION.\n\n--help display this help and exit\n",
                "subsections": [
                    {
                        "name": "--version",
                        "content": "output version information and exit\n\nAn  omitted  EXPRESSION  defaults  to false.  Otherwise, EXPRESSION is true or false and sets\nexit status.  It is one of:\n\n( EXPRESSION )\nEXPRESSION is true\n\n! EXPRESSION\nEXPRESSION is false\n\nEXPRESSION1 -a EXPRESSION2\nboth EXPRESSION1 and EXPRESSION2 are true\n\nEXPRESSION1 -o EXPRESSION2\neither EXPRESSION1 or EXPRESSION2 is true\n",
                        "long": "--version"
                    },
                    {
                        "name": "-n",
                        "content": "the length of STRING is nonzero\n\nSTRING equivalent to -n STRING\n",
                        "flag": "-n"
                    },
                    {
                        "name": "-z",
                        "content": "the length of STRING is zero\n\nSTRING1 = STRING2\nthe strings are equal\n\nSTRING1 != STRING2\nthe strings are not equal\n\nINTEGER1 -eq INTEGER2\nINTEGER1 is equal to INTEGER2\n\nINTEGER1 -ge INTEGER2\nINTEGER1 is greater than or equal to INTEGER2\n\nINTEGER1 -gt INTEGER2\nINTEGER1 is greater than INTEGER2\n\nINTEGER1 -le INTEGER2\nINTEGER1 is less than or equal to INTEGER2\n\nINTEGER1 -lt INTEGER2\nINTEGER1 is less than INTEGER2\n\nINTEGER1 -ne INTEGER2\nINTEGER1 is not equal to INTEGER2\n\nFILE1 -ef FILE2\nFILE1 and FILE2 have the same device and inode numbers\n\nFILE1 -nt FILE2\nFILE1 is newer (modification date) than FILE2\n\nFILE1 -ot FILE2\nFILE1 is older than FILE2\n",
                        "flag": "-z"
                    },
                    {
                        "name": "-b",
                        "content": "FILE exists and is block special\n",
                        "flag": "-b"
                    },
                    {
                        "name": "-c",
                        "content": "FILE exists and is character special\n",
                        "flag": "-c"
                    },
                    {
                        "name": "-d",
                        "content": "FILE exists and is a directory\n",
                        "flag": "-d"
                    },
                    {
                        "name": "-e",
                        "content": "FILE exists\n",
                        "flag": "-e"
                    },
                    {
                        "name": "-f",
                        "content": "FILE exists and is a regular file\n",
                        "flag": "-f"
                    },
                    {
                        "name": "-g",
                        "content": "FILE exists and is set-group-ID\n",
                        "flag": "-g"
                    },
                    {
                        "name": "-G",
                        "content": "FILE exists and is owned by the effective group ID\n",
                        "flag": "-G"
                    },
                    {
                        "name": "-h",
                        "content": "FILE exists and is a symbolic link (same as -L)\n",
                        "flag": "-h"
                    },
                    {
                        "name": "-k",
                        "content": "FILE exists and has its sticky bit set\n",
                        "flag": "-k"
                    },
                    {
                        "name": "-L",
                        "content": "FILE exists and is a symbolic link (same as -h)\n",
                        "flag": "-L"
                    },
                    {
                        "name": "-N",
                        "content": "FILE exists and has been modified since it was last read\n",
                        "flag": "-N"
                    },
                    {
                        "name": "-O",
                        "content": "FILE exists and is owned by the effective user ID\n",
                        "flag": "-O"
                    },
                    {
                        "name": "-p",
                        "content": "FILE exists and is a named pipe\n",
                        "flag": "-p"
                    },
                    {
                        "name": "-r",
                        "content": "FILE exists and the user has read access\n",
                        "flag": "-r"
                    },
                    {
                        "name": "-s",
                        "content": "FILE exists and has a size greater than zero\n",
                        "flag": "-s"
                    },
                    {
                        "name": "-S",
                        "content": "FILE exists and is a socket\n",
                        "flag": "-S"
                    },
                    {
                        "name": "-t",
                        "content": "",
                        "flag": "-t"
                    },
                    {
                        "name": "-u",
                        "content": "FILE exists and its set-user-ID bit is set\n",
                        "flag": "-u"
                    },
                    {
                        "name": "-w",
                        "content": "FILE exists and the user has write access\n",
                        "flag": "-w"
                    },
                    {
                        "name": "-x",
                        "content": "FILE exists and the user has execute (or search) access\n\nExcept for -h and -L, all FILE-related tests dereference symbolic links.  Beware that  paren‐\ntheses  need to be escaped (e.g., by backslashes) for shells.  INTEGER may also be -l STRING,\nwhich evaluates to the length of STRING.\n\nNOTE: Binary -a and -o are inherently ambiguous.  Use 'test EXPR1 &&  test  EXPR2'  or  'test\nEXPR1 || test EXPR2' instead.\n\nNOTE:  [  honors  the  --help  and --version options, but test does not.  test treats each of\nthose as it treats any other nonempty STRING.\n\nNOTE: your shell may have its own version of test and/or [, which usually supersedes the ver‐\nsion described here.  Please refer to your shell's documentation for details  about  the  op‐\ntions it supports.\n",
                        "flag": "-x"
                    }
                ]
            },
            "AUTHOR": {
                "content": "Written by Kevin Braunsdorf and Matthew Bradburn.\n",
                "subsections": []
            },
            "REPORTING BUGS": {
                "content": "GNU coreutils online help: <https://www.gnu.org/software/coreutils/>\nReport any translation bugs to <https://translationproject.org/team/>\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "Copyright  ©  2023 Free Software Foundation, Inc.  License GPLv3+: GNU GPL version 3 or later\n<https://gnu.org/licenses/gpl.html>.\nThis is free software: you are free to change and redistribute it.  There is NO WARRANTY,  to\nthe extent permitted by law.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "access(2)\n\nFull documentation <https://www.gnu.org/software/coreutils/test>\nor available locally via: info '(coreutils) test invocation'\n\nGNU coreutils 9.4                           January 2026                                     TEST(1)",
                "subsections": []
            }
        }
    }
}