#!/bin/bash set -e keyphrase=$1 folder=$2 if test -z "$keyphrase"; then echo 'Keyphrase must not be empty' exit fi if test -z "$folder"; then echo 'Target folder name must not be empty' exit fi i=0 mkdir -p "$folder" for file in $(cat index.tsv | grep -i "$keyphrase" | awk '{printf("threads/%s/%08d.txt\n", $NF, $1)}'); do cp $file $folder/$(printf "%04d" "$i").txt i=$((i + 1)) done