Say I have the following file:test_file-1234-master.tar.gzI have tried to un tar using the following commands tar -xf test_file-[0-9]+-master.tar.gz tar -xf test_file-[:digit]-master.tar.gzBut no luck. How to match this pattern ?NOTE: There will be always one file. I'm not trying to open multiple files.
Regex file name with multiple digits
files;filenames;wildcards
With ksh, bash -O extglob and zsh -o kshglob only:test_file-+([[:digit:]])-master.tar.gzIn bash, you have to set the extglob option first. This +(...) matches one or more occurrences of the given patterns. [:digit:] when inside a [...] bracket expression is a POSIX defined character class which includes Indo-Arabic decimal digits ([[:digit:]] is the same as [0123456789] or [0-9]).It will match:test_file-1234-master.tar.gztest_file-1-master.tar.gztest_file-123456789-master.tar.gzIt will not match:test_file-1b-master.tar.gztest_file--master.tar.gztest_file-a1-master.tar.gztest_file-abcd-master.tar.gztest_file--master.tar.gz # roman numeraltest_file--master.tar.gz  # Eastern Arabic decimal digitThe tar command in your question should then be done like this (with a loop):shopt -s extglob # bash# setopt kshglob # zshfor f in test_file-+([[:digit:]])-master.tar.gz; do    tar xf $fdoneThe more idiomatic short syntax in zsh is:setopt extendedglobfor f (test_file-[0-9]##-master.tar.gz) tar xf $f(# being the extendedglob equivalent of regexp *, and ## or +).