#!/usr/bin/env bash
set -euo pipefail

outdir="x_y_removed"
mkdir -p "$outdir"

# Process all your *_filter.txt files in the current directory
for f in *RUVr_k3_filter.txt; do
  [[ -e "$f" ]] || { echo "No matching files: *RUVr_k3_filter.txt" >&2; exit 1; }

  base="$(basename "$f")"
  out="$outdir/$base"

  # remove chrX and chrY rows (keeps headerless BED-like rows)
  awk 'BEGIN{FS=OFS="\t"} $1!="chrX" && $1!="chrY"' "$f" > "$out"
done

echo "Done. New files saved in: $outdir/"
