[AWK] process field which ends with .dat

This is my first day with awk scripting..Please pardon my ignorance, if any..

I am trying to remove all files ending with .dat

ls -1R xyz/ | awk '$1==*.dat{print "rm " $1}' | bash

ls -1R --> will list files/directories one per line, even the sub directories

I try to match first field of line == *.dat , if true.. remove that file,i know I have not taken care of subdirectory... But that is what I am trying..Any idea how to do it..:confused:

Maybe awk isn't the best method... Try this:

find xyz -type f -name "*.dat" -exec rm {}\;

For the first execution, omit the "-exec ..." part and check the output before removing anything!

find . -name "*.dat" | xargs rm

ls -1R *.dat | xargs rm