block by joyrexus 5322129

Move files with specified pattern in first line to target dir.

Sift files by header

Suppose you have a set of files you want to partition on the basis of the first line in the file.

This script enables you to move a filtered subset (based on the header line) to a target directory.

You specify the pattern in the first line of the files you wish to move. Those files containing the pattern in their header get moved, those without don’t.

Usage

head_move.sh PATTERN FILES... DIR

Example

/surveys
    a.tsv
    b.tsv
    c.tsv
    d.tsv
    .
    .
    .
    /standard
    /extended


head_move.sh "Q14" *.tsv extended

head_move.sh