-1

So I have text output bellow from a 'mediinfo VIDEO.mkv':

General
Unique ID                                : 190778803810831492312123193779943 (0x8F265C1B107A4D595F723237C370C7074FB7)
Complete name                            : VIDEO.mkv
Format                                   : Matroska
Format version                           : Version 4 / Version 2

Video
ID                                       : 1
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main@L3@Main
Codec ID                                 : V_MPEGH/ISO/HEVC

I need to GREP or AWK out the Format: HEVC bellow Video. I wasn't sure how to proceed as I could regex 'Format' but then I get back multiple rows (Matroska and HEVC). I haven't found any handy hints.

Ideas?

Chase Westlye
  • 381
  • 2
  • 6
  • 20
  • 1
    Please avoid *"Give me the codez"* questions that have been asked and answered so many times you have to make an effort to avoid finding an answer. Instead show the script you are working on and state where the problem is. Also see [How much research effort is expected of Stack Overflow users?](https://meta.stackoverflow.com/q/261592/608639) – jww Aug 27 '18 at 10:47

3 Answers3

0
  • If "Matroska" is fixed you can do it by mediinfo VIDEO.mkv | grep "Format " test.fi | grep -v "Matroska"
  • If output format is fixed then you do it by mediinfo VIDEO.mkv | grep "Format " test.fi | tail -n1

grep -v will ignore matching line, tail will print specified number o lines from the last.

Madhan S
  • 877
  • 6
  • 11
0
mediinfo VIDEO.mkv | awk -v RS= '/^Video/{print $7}' 
HEVC

You can use awk with RS set to blank and print the desired column number.

P....
  • 17,421
  • 2
  • 32
  • 52
-1

Obviously many ways to solve this, but sed seems like a natural fit here:

$ sed -n '/Video/,$ { s/Format *: //p }' file
HEVC
randomir
  • 17,989
  • 1
  • 40
  • 55