BASH - file selection by multiple patterns in zenity

蓝咒 提交于 2020-05-13 05:48:08

问题


Im pretty new to zenity and bash. Im trying to make file selection window that will display only the ones with .ogg, .aac and .wav extension. I tried this, but it doesn't work.

option=`zenity --file-selection --file-filter=*.ogg | *.aac`

For one extension it's working as intented:

option=`zenity --file-selection --file-filter=*.ogg`

Zenity man provides information:

--file-filter=NAME | PATTERN1 PATTERN2
Sets a filename filter

I dont really understand how am I supposed to use it. Can someone show me some examples?


回答1:


Ok I found the solution, maybe someone will use it in the future:

zenity --file-selection --file-filter=""*.ogg" "*.wav" "*.aac""



回答2:


Special bash symbols | and * needs escaping (backslash) or quoting (single or double), and you have succeeded with that. With single quotes the argument is passed literally to zenity.

Repeat the --file-filter option if you want more filter choices For example, you may want two filters "All files" and "Music files" in the file selection window:

zenity --file-selection --file-filter='Music files (ogg,wav,aac) | *.ogg *.wav *.aac' --file-filter='All files | *'


来源:https://stackoverflow.com/questions/16267042/bash-file-selection-by-multiple-patterns-in-zenity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!