Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 3
    You probably meant if [ "$#" -ne 1 ] || ! [[ $1 =~ ^-?[0123456789]$ ]]; then exit 1; fi which can also be written if [[ $# -ne 1 || ! $1 =~ ^-?[0123456789]$ ]]; then exit 1; fi. Or in standard sh: case $#:$1 in (1:[0123456789] | 1:-[0123456789]) ;; (*) exit 1; esac Commented May 25, 2022 at 19:18
  • The expression works fine but there is no valid reason to mix these. Commented May 25, 2022 at 19:19
  • Way easier indeed @StéphaneChazelas!! I am still learning bash.. Thank you. That was very helpful! Commented May 25, 2022 at 19:21