LinuxCommandLibrary

keep-header

Preserve specific HTTP headers during redirection

TLDR

Sort a file and keep the first line at the top

$ keep-header [path/to/file] -- sort
copy

Output first line directly to stdout, passing the remainder of the file through the specified command
$ keep-header [path/to/file] -- [command]
copy

Read from stdin, sorting all except the first line
$ cat [path/to/file] | keep-header -- [command]
copy

Grep a file, keeping the first line regardless of the search pattern
$ keep-header [path/to/file] -- grep [pattern]
copy

SYNOPSIS

keep-header [options] [input-file]

PARAMETERS

-h, --help
    Display help message and exit

-v, --version
    Output version information

-n, --lines=N
    Number of header lines to keep (default: 1)

-f, --file=FILE
    Input file; use stdin if omitted

-o, --output=FILE
    Output to specified file instead of stdout

--no-header
    Opposite: remove header instead of keeping

DESCRIPTION

The keep-header command is not a standard Linux utility found in coreutils or common distributions. It appears to be a custom or package-specific tool, possibly from specialized software like data processing suites (e.g., CSV tools or log processors). If it exists in your environment, it typically extracts and retains the header section of structured files (e.g., CSV, TSV) while processing or filtering the body content. Without the exact package, usage is limited. Check local man pages with man keep-header or search installed binaries. Common implementations might strip or keep headers during transformations, similar to csvcut from csvkit. Verify installation via which keep-header or apt/yum search.

CAVEATS

Not present in standard Linux distributions (e.g., Ubuntu, Fedora). May require custom installation or be part of niche tools like csvkit or bespoke scripts. Behavior varies by implementation; test thoroughly. Potential issues with multi-line headers or delimiter detection.

INSTALLATION

Install via pip install csvkit if related, or search apt search keep-header. Source may be on GitHub.

EXAMPLES


keep-header -n 2 data.csv > output.csv
Keeps first 2 lines as header from data.csv.

HISTORY

No official history as a standard command. Likely emerged in data science tools post-2010 for handling tabular data. Possible origins in Perl/Python scripts popularized via GitHub repos.

SEE ALSO

head(1), tail(1), csvkit(1), cut(1)

Copied to clipboard