fish - 遍历标准输入鱼(上下文:按流派 grep 过滤音乐文件)
问题描述
我有这个:
for file in **/*.ogg;
if ffprobe "$file" 2>&1 | sed -E -n 's/^ *GENRE *: (.*)/\1/p' | grep -q "$argv";
echo "$file"
else
end
end
但我想把它变成一个函数,它将文件名列表作为标准输入:
$ find . -maxdepth 1 -not -type d -exec du -h {} + | cut -f2 | filterByGenre Classical
解决方案
你可以做
function filterByGenre
while read line
do stuff with $line
end
end
或者
function filterByGenre
set listOfLines (cat)
for line in $listOfLines
do stuff with $line
end
end
推荐阅读
- wordpress - Styles for current item with anchor links with absolute path in Wordpress menu
- jmeter - Jmeter run test plan from command line with external link to properties
- javascript - 在 React 和 Redux 中使用 setTimeout
- c++ - 什么时候在类中检查函数的定义?
- php - multi language website by codeigniter with language in link
- bluetooth - Android 与自定义 USB 蓝牙适配器配对
- python - Matplotlib - MatplotlibDeprecationWarning
- c++ - 如何将参数传递给已经开始运行的线程
- linux - 从输入(sshpass?)在多个本地服务器上执行 SSH 远程 cmd exec
- vue.js - 计算属性需要等待异步数据