Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 26 lines (21 sloc) 701 Bytes
#!/usr/bin/env python
"""
hwrap [pipeline command to wrap]
Assume stdin has a header and the rest are rows.
Print header, then pass on only the rows to wrapped command's stdin.
Examples:
cat file_with_header.tsv | hwrap tabsort -k3
cat file_with_header.tsv | hwrap tail
cat file_with_header.tsv | hwrap grep bla
cat file_with_header.tsv | hwrap bash -c "grep bla | head"
"""
import sys,os,subprocess
if sys.stdin.isatty():
print>>sys.stderr, __doc__.strip()
sys.exit(1)
sys.stdin = open('/dev/stdin','U',buffering=0)
sys.stdout = open('/dev/stdout','w',buffering=0)
header = sys.stdin.readline()
print header[:-1]
args = sys.argv[1:]
subprocess.call(args, stdin=sys.stdin, stdout=sys.stdout)
Something went wrong with that request. Please try again.