Вы также можете использовать glob оболочки, чтобы получить список файлов. Этот подход имеет то преимущество, что не использует внешнюю программу (find) и не требует каких-либо ограничений на тип файла (например, *war):
#!/usr/bin/env bash
## Collect the files in the array $files
files=( ~/foo/war/* )
## Enable extended globbing. This lets us use @(foo|bar) to
## match either 'foo' or 'bar'.
shopt -s extglob
## Start building the string to match against.
string="@(${files[0]}"
## Add the rest of the files to the string
for((i=1;i<${#files[@]};i++))
do
string+="|${files[$i]}"
done
## Close the parenthesis. $string is now @(file1|file2|...|fileN)
string+=")"
## Show the menu. This will list all files and the string "quit"
select file in "${files[@]}" "quit"
do
case $file in
## If the choice is one of the files (if it matches $string)
$string)
## Do something here
echo "$file"
## Uncomment this line if you don't want the menu to
## be shown again
# break;
;;
"quit")
## Exit
exit;;
*)
file=""
echo "Please choose a number from 1 to $((${#files[@]}+1))";;
esac
done
Вы посмотрели KCharSelect? Вот ссылка для него на packages.ubuntu.com (natty-specific)
Вы посмотрели KCharSelect? Вот ссылка для него на packages.ubuntu.com (natty-specific)
Вы посмотрели KCharSelect? Вот ссылка для него на packages.ubuntu.com (natty-specific)
Вы посмотрели KCharSelect? Вот ссылка для него на packages.ubuntu.com (natty-specific)
Вы посмотрели KCharSelect? Вот ссылка для него на packages.ubuntu.com (natty-specific)
Вы посмотрели KCharSelect ? Вот ссылка на него на packages.ubuntu.com (специально для natty)
Вы посмотрели KCharSelect ? Вот ссылка на него на packages.ubuntu.com (специально для natty)
Вы посмотрели KCharSelect ? Вот ссылка на него на packages.ubuntu.com (специально для natty)