#!/bin/bash for file in *c do file_sans_c=$(echo "$file" | sed 's/c$//') if [ -f "$file_sans_c" ] then echo "Removing $file" rm "$file" fi done