#!/usr/bin/perl my @normal_rows = (2..66); my $i; my @rows_to_remove = (); my $cmd; # pick all but 25 rows to remove for($i=0; $i<(65 - 25); $i++){ push @rows_to_remove, splice(@normal_rows, int rand @normal_rows, 1); } my $nrows = scalar(@rows_to_remove); print "num rows to be removed: $nrows\n"; my $str_rm = ""; foreach my $num (@rows_to_remove){ print ">>> will remove row $num\n"; $str_rm = $str_rm."$num"."d;"; } $cmd = "sed --in-place '$str_rm' *txt"; print "$cmd\n"; system($cmd);