#!/bin/bash source=$(zenity --file-selection --directory) filetype=$(zenity --entry --width=300 --title="enter filetype" --text="format : *.doc or *.mp3") shopt -s nullglob if [[ "shopt -s nullglob" == 0 ]]; then echo "this filetype doesn't exist"; fi cd $source for files in $filetype do array=( $files ) echo $files done