Ale*_*sil 2 linux pdf bash find bash-function
你好 Bash 超级英雄,
我正在尝试创建一个简单的 bash 函数,该函数将输出从find传送到 aa pdf 查看器,类似于但仅限于evince。
function findpapers {
find ~/papers/ -name *$1* | evince
}
Run Code Online (Sandbox Code Playgroud)
上述功能打开查看器但不显示任何所需的文件/路径。最终,我想显示从find输出的所有pdf 。一个简单的查找命令,例如:
$ find /home/alex/papers/ -name *erebus*
Run Code Online (Sandbox Code Playgroud)
创建一个输出,如:
/home/alex/papers/2000/rowe/seismic_and_acoustic_observations_at_mount_erebus_volcano_ross_island_antarctica.pdf
/home/alex/papers/2008/Jones/infrasonic_tracking_of_large_bubble_bursts_and_ash_venting_at_erebus_volcano_antarctica.pdf
Run Code Online (Sandbox Code Playgroud)
然后的想法是在查看器中显示这两个 pdf 文件。
有什么想法或建议吗?如果有帮助,我正在使用 Linux Mint。提前致谢!
您需要 evince 命令行上的文件名列表,而不是它的标准输入。
用
evince $(find /home/alex/papers/ -name *erebus*)
Run Code Online (Sandbox Code Playgroud)
或者
find /home/alex/papers/ -name *erebus* | xargs evince
Run Code Online (Sandbox Code Playgroud)
在 linux(或任何使用 find 和 xargs 的 gnu 版本的操作系统)上,如果文件名可能包含空格,最好使用
find /home/alex/papers/ -name *erebus* -print0 | xargs -0 evince
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1615 次 |
| 最近记录: |