return everything above the line that starts with "diff;"
Usando sed
Nesse caso, tente:
sed '/^diff/,$d' a.patch
O texto acima exclui todas as linhas do primeiro que corresponde ao regex ^diff
até a última linha, $
.
Uma versão um pouco mais eficiente sai quando a linha contendo ^diff
é atingida:
sed -n '/^diff/q; p' a.patch
Usando seu arquivo de amostra:
$ sed -n '/^diff/q; p' a.patch
Title: Font Array Support
Modifies st to support user-defined fallback fonts specified in an array
defined as 'static const char *fonts[]'. This change also resolves an issue
where fallback fonts were used in place of default fonts in an inconsistent
manner which caused identical sets of text to sometimes use different fonts. In
the following example, DejaVu Sans Mono is the primary font with two others
specified as fallbacks:
static const char *fonts[] = {
"DejaVu Sans Mono",
"VL Gothic",
"WenQuanYi Micro Hei",
};
Usando o awk
Usando o awk:
awk '/^diff/{exit} 1' a.patch
O 1
é a abreviação abreviada de awk para impressão na linha. No entanto, quando a primeira linha que corresponde ao regex ^diff
é atingida, o programa sai.
$ awk '/^diff/{exit} 1' a.patch
Title: Font Array Support
Modifies st to support user-defined fallback fonts specified in an array
defined as 'static const char *fonts[]'. This change also resolves an issue
where fallback fonts were used in place of default fonts in an inconsistent
manner which caused identical sets of text to sometimes use different fonts. In
the following example, DejaVu Sans Mono is the primary font with two others
specified as fallbacks:
static const char *fonts[] = {
"DejaVu Sans Mono",
"VL Gothic",
"WenQuanYi Micro Hei",
};