How to get the counts of deleted files in unix/linux

How to get the counts of deleted files in unix/linux

If you want to get the deleted files count by your rm command, use the verbose option (-v) and wc -l. 

To delete a file

rm -f source_fname_*.txt

To get the counts of deleted files

rm -vf source_fname_*.txt | wc -l 

To find & delete the files and get the counts

find infa/bdm/server/source/path -type f -iname source_fname_*.txt -exec rm -vf {} \; | wc -l

rm : remove files or directories
-f,  : force ignore nonexistent files, never prompt.
-v,  : verbose explain what is being done.
wc -l : To get the line count

Liked the content?? Please Like FB page & subscribe the channel!
Let’s learn together!