I have images, I need to delete some files with the same size. But no need to remove all such images, but only the next in the queue (in alphabetical order):1.png    # 23,5 Kb2.png    # 24,6 Kb4.png    # 24,6 Kb > remove8.png    # 24,6 Kb > remove16.png   # 23,5 Kb
How to remove the same size files in a directory?
command line
If you're on Linux or otherwise have access to GNU tools, you can do this:last=-1; find . -type f -name '*.png' -printf '%f\0' | sort -nz |     while read -d '' i; do         s=$(stat -c '%s' $i);         [[ $s = $last ]] && rm $i;     last=$s; doneExplanationlast=-1 : set the variable $last to -1.find . -type f -name '*.png' -printf '%f\0' : find all files in the current directory whose name ends in .png and print their name followed by the NULL character. sort -gz : sort \0-separated input (-z) numerically (-n). This results in a sorted list of file names. while read -d '' i; do : read the list of file names. The -d '' sets the field delimiter to \0 which is needed to process NULL-separated data correctly. s=$(stat -c '%s' $i); : the variable $s now holds the size of the current file ($i). [[ $s = $last ]] && rm $i; : if the current file's size is the same as the last file's size, delete the file. last=$s : set $last to the current file's size. Now, if the next file has the same size, the previous step will delete it. 