LinuxCommandLibrary

keep-header

preserves the first line of a file while passing the remaining lines through

TLDR

Sort file keeping header
$ keep-header [file] -- sort
copy
Filter with grep keeping header
$ keep-header [file] -- grep [pattern]
copy
Pipe through multiple commands
$ keep-header [file] -- sort | head -20
copy

SYNOPSIS

keep-header file -- command [args...]

DESCRIPTION

keep-header preserves the first line (header) of a file while passing the remaining lines through another command. Useful for processing CSV or TSV files where you want to sort or filter data without losing column headers.

SEE ALSO

head(1), tail(1), sort(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard