You are trying to remove the files whose names are given by ls -lt | awk '{if ($8 == 2006) print $9}'; If you are in the same directory, or you have full pathnames, you can do just (and avoid the 'for do done' loop) rm $( ls -lt | awk '{if ($8 == 2006) print $9}' ) If this exceeds the maximum length of a line, just use xargs also.