#! /usr/bin/gawk -f # Last edited on 2022-12-11 07:24:45 by stolfi # Reads a file that has fields "{tag} {size} {date} {fname} {dir[1]} {dir[2]}..." # where the {tag} is in column 1 and is a digit in {0..9}, # {fname} is the tail part of a pathname, and {dir[1]}, {dir[2]}, ... # are two or more directories where a copy of that file exists. # Writes commands "rm -v {dir[tag]}/{fname}" for every entry with a non-zero tag. /^[0][ ]/ { next; } /^[1-9][ ]/ { tg=$1; sz=$2; dt=$3; fn=$4; for (k=5; k<=NF;k++) { if (k == tg+4) { pt = ("'" $(k) fn "'"); printf "rm -v %-60s # %14d %s ", pt,sz,dt; } } for (k=5; k<=NF;k++) { if (k != tg+4) { printf " %s", $(k); } } printf "\n"; next; } //{ printf "** ERROR\n" > "/dev/stderr"; exit(1); }