{
    "content": [
        {
            "type": "text",
            "text": "# Expr (man)\n\n## NAME\n\nexpr - evaluate expressions\n\n## SYNOPSIS\n\nexpr EXPRESSION\nexpr OPTION\n\n## DESCRIPTION\n\n--help display this help and exit\n\n## TLDR\n\n> Evaluate expressions and manipulate strings.\n\n- Get the length of a specific string:\n  `expr length \"{{string}}\"`\n- Get the substring of a string with a specific length:\n  `expr substr \"{{string}}\" {{from}} {{length}}`\n- Match a specific substring against an anchored pattern:\n  `expr match \"{{string}}\" '{{pattern}}'`\n- Get the first char position from a specific set in a string:\n  `expr index \"{{string}}\" \"{{chars}}\"`\n- Calculate a specific mathematic expression:\n  `expr {{expression1}} {{+|-|*|/|%}} {{expression2}}`\n- Get the first expression if its value is non-zero and not null otherwise get the second one:\n  `expr {{expression1}} \\| {{expression2}}`\n- Get the first expression if both expressions are non-zero and not null otherwise get zero:\n  `expr {{expression1}} \\& {{expression2}}`\n\n*Source: tldr-pages*\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION** (1 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": "Expr",
        "section": "",
        "mode": "man",
        "summary": "expr - evaluate expressions",
        "synopsis": "expr EXPRESSION\nexpr OPTION",
        "tldr_summary": "Evaluate expressions and manipulate strings.",
        "tldr_examples": [
            {
                "description": "Get the length of a specific string",
                "command": "expr length \"{{string}}\""
            },
            {
                "description": "Get the substring of a string with a specific length",
                "command": "expr substr \"{{string}}\" {{from}} {{length}}"
            },
            {
                "description": "Match a specific substring against an anchored pattern",
                "command": "expr match \"{{string}}\" '{{pattern}}'"
            },
            {
                "description": "Get the first char position from a specific set in a string",
                "command": "expr index \"{{string}}\" \"{{chars}}\""
            },
            {
                "description": "Calculate a specific mathematic expression",
                "command": "expr {{expression1}} {{+|-|*|/|%}} {{expression2}}"
            },
            {
                "description": "Get the first expression if its value is non-zero and not null otherwise get the second one",
                "command": "expr {{expression1}} \\| {{expression2}}"
            },
            {
                "description": "Get the first expression if both expressions are non-zero and not null otherwise get zero",
                "command": "expr {{expression1}} \\& {{expression2}}"
            }
        ],
        "tldr_source": "official",
        "flags": [
            {
                "flag": "",
                "long": "--version",
                "arg": null,
                "description": "output version information and exit Print the value of EXPRESSION to standard output. A blank line below separates increasing precedence groups. EXPRESSION may be: ARG1 | ARG2 ARG1 if it is neither null nor 0, otherwise ARG2 ARG1 & ARG2 ARG1 if neither argument is null or 0, otherwise 0 ARG1 < ARG2 ARG1 is less than ARG2 ARG1 <= ARG2 ARG1 is less than or equal to ARG2 ARG1 = ARG2 ARG1 is equal to ARG2 ARG1 != ARG2 ARG1 is unequal to ARG2 ARG1 >= ARG2 ARG1 is greater than or equal to ARG2 ARG1 > ARG2 ARG1 is greater than ARG2 ARG1 + ARG2 arithmetic sum of ARG1 and ARG2 ARG1 - ARG2 arithmetic difference of ARG1 and ARG2 ARG1 * ARG2 arithmetic product of ARG1 and ARG2 ARG1 / ARG2 arithmetic quotient of ARG1 divided by ARG2 ARG1 % ARG2 arithmetic remainder of ARG1 divided by ARG2 STRING : REGEXP anchored pattern match of REGEXP in STRING match STRING REGEXP same as STRING : REGEXP substr STRING POS LENGTH substring of STRING, POS counted from 1 index STRING CHARS index in STRING where any CHARS is found, or 0 length STRING length of STRING + TOKEN interpret TOKEN as a string, even if it is a keyword like 'match' or an operator like '/' ( EXPRESSION ) value of EXPRESSION Beware that many operators need to be escaped or quoted for shells. Comparisons are arith‐ metic if both ARGs are numbers, else lexicographical. Pattern matches return the string matched between \\( and \\) or null; if \\( and \\) are not used, they return the number of char‐ acters matched or 0. Exit status is 0 if EXPRESSION is neither null nor 0, 1 if EXPRESSION is null or 0, 2 if EX‐ PRESSION is syntactically invalid, and 3 if an error occurred."
            }
        ],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 2,
                "subsections": [
                    {
                        "name": "--version",
                        "lines": 75,
                        "long": "--version"
                    }
                ]
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "REPORTING BUGS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 4,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "expr - evaluate expressions\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "expr EXPRESSION\nexpr OPTION\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "--help display this help and exit\n",
                "subsections": [
                    {
                        "name": "--version",
                        "content": "output version information and exit\n\nPrint  the  value  of EXPRESSION to standard output.  A blank line below separates increasing\nprecedence groups.  EXPRESSION may be:\n\nARG1 | ARG2\nARG1 if it is neither null nor 0, otherwise ARG2\n\nARG1 & ARG2\nARG1 if neither argument is null or 0, otherwise 0\n\nARG1 < ARG2\nARG1 is less than ARG2\n\nARG1 <= ARG2\nARG1 is less than or equal to ARG2\n\nARG1 = ARG2\nARG1 is equal to ARG2\n\nARG1 != ARG2\nARG1 is unequal to ARG2\n\nARG1 >= ARG2\nARG1 is greater than or equal to ARG2\n\nARG1 > ARG2\nARG1 is greater than ARG2\n\nARG1 + ARG2\narithmetic sum of ARG1 and ARG2\n\nARG1 - ARG2\narithmetic difference of ARG1 and ARG2\n\nARG1 * ARG2\narithmetic product of ARG1 and ARG2\n\nARG1 / ARG2\narithmetic quotient of ARG1 divided by ARG2\n\nARG1 % ARG2\narithmetic remainder of ARG1 divided by ARG2\n\nSTRING : REGEXP\nanchored pattern match of REGEXP in STRING\n\nmatch STRING REGEXP\nsame as STRING : REGEXP\n\nsubstr STRING POS LENGTH\nsubstring of STRING, POS counted from 1\n\nindex STRING CHARS\nindex in STRING where any CHARS is found, or 0\n\nlength STRING\nlength of STRING\n\n+ TOKEN\ninterpret TOKEN as a string, even if it is a\n\nkeyword like 'match' or an operator like '/'\n\n( EXPRESSION )\nvalue of EXPRESSION\n\nBeware that many operators need to be escaped or quoted for shells.  Comparisons  are  arith‐\nmetic  if  both  ARGs  are  numbers, else lexicographical.  Pattern matches return the string\nmatched between \\( and \\) or null; if \\( and \\) are not used, they return the number of char‐\nacters matched or 0.\n\nExit status is 0 if EXPRESSION is neither null nor 0, 1 if EXPRESSION is null or 0, 2 if  EX‐\nPRESSION is syntactically invalid, and 3 if an error occurred.\n",
                        "long": "--version"
                    }
                ]
            },
            "AUTHOR": {
                "content": "Written by Mike Parker, James Youngman, and Paul Eggert.\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": "Full documentation <https://www.gnu.org/software/coreutils/expr>\nor available locally via: info '(coreutils) expr invocation'\n\nGNU coreutils 9.4                           January 2026                                     EXPR(1)",
                "subsections": []
            }
        }
    }
}