I want to delete those files without the extension I need, so I just write this perl script. The directory can also be specified on the command line. I list all those extensions I need as a pattern.
usestrict;usewarnings;useutf8;useCwd;my$targetDir=$ARGV[0]||getcwd;chdir$targetDir;my$pattern=qr/\.(md|py|php|sh|bash|zsh|vimrc|eamcs|c|cpp|java|pl|js|css|html|rb|txt)$/i,my@file_list;opendir(my$dh,$targetDir)||die"can't opendir $targetDir: $!";while(readdir$dh){nextunless-f;nextif$_=~$pattern;push@file_list,$_;}closedir$dh;print"The following files are going to be deleted: @file_list\n";unlink@file_list;__END__=pod=head1 NAMEdelete-files.pl -delete those files without the extension as specifed in the pattern=head1 SYNOPSIS $ delete-filesIt reads the files in the directory where you execute this script, and delete thosenot having the extension as is specified "(md|py|php|sh|bash|zsh|vimrc|eamcs|c|cpp|java|pl|js|css|html|rb|txt)"Please use this script carefully. If you have somefile without extension which you alsoconsider them important, they maybe deleted.Thanks,Steven=cut