怎么办"每个"从发现的输出? [英] How to do "for each" on output from find?

查看:106
本文介绍了怎么办"每个"从发现的输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想找到所有 MP4 文件为1920x1080。

I would like to find all mp4 files that is 1920x1080.

如果我

find . -type f -name \*.mp4 -exec ffprobe '{}' \; 2>&1

它会找到所有的 MP4 文件和显示视频信息。例如。将输出包含(其它线路之间)

it will find all mp4 files and show the video info. E.g. will the output contain (among other lines)

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './5432223.mp4':
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 1744 kb/s, 29.97 fps, 29.97 tbr, 60k tbn, 59.94 tbc

我现在的想法是

find . -type f -name \*.mp4 -print0|xargs -0 -n1 echo
for f in $(find . -type f -name \*.mp4); do ffprobe $f 2>&1 | grep 1920x1080;done

在这里我无法弄清楚如何将如果grep的-q 1920×1080 ,并在第一,并在文件名中第二个空格食堂输出了。

where I can't figure out how to incorporate if grep -q 1920x1080 and in the first, and in the second white spaces in filenames messes the output up.

我如何输出只与路径文件名,如果输出匹配 1920×1080

How do I output only the filename with path if the output matches 1920x1080?

推荐答案

您可能想给exec一个shell。是这样的:

You probably want to exec a shell. Something like:

find . -type f -name \*.mp4 -exec sh -c 'ffprobe "$0" 2>&1 |
    grep -q 1920x1080 && echo "$0"' {} \;

这篇关于怎么办"每个"从发现的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆