You can use set as shown below. The shell will expand the wildcard and set will designate the files as positional parameters that can be accessed using $1 , $2 , etc.
# set nullglob so that if no matching files are found, the wildcard expands to a null string shopt -s nullglob set -- /path/to/folder/*.tar.gz
Using parse ls not recommended, as it will not process filenames containing newlines. In addition, grep not required because you can just do ls /path/to/folder/*.tar.gz | head -1 ls /path/to/folder/*.tar.gz | head -1 .
dogbane
source share