View Single Post
Old 05-31-2019, 07:10 PM
Antares14943 Antares14943 is offline
Registered User
Join Date: Jul 2017
Posts: 1
Bash script

I wrote this while trying to troubleshoot a startup issue and thought I would share. This outputs a list of "rm -rf <file or folder>" commands. They are only suggestions! Do not run the commands if you aren't comfortable.

#!/usr/bin/env bash

echo "Finding files. This may take several minutes."
echo "See progress by running: tail -f ${tmp_file}"
sudo find -E / -regex ".*[Vv]an *[Dd]yke.*" 2>/dev/null >"${tmp_file}"
sudo find -E / -regex ".*[Ss]ecure *[Cc][Rr][Tt].*" 2>/dev/null >>"${tmp_file}"

echo "create rm -rf \"<file>\" line for everything we found"
sed -e 's/^/rm -rf "/' "${tmp_file}" > "${delete_me}"
sed -i -e 's/$/"/' "${delete_me}"

echo "Cleaning up output"
# Edit this list if you want to include files matching these patterns.
cat "${delete_me}" | \
grep -v "SecureCRT Logs"  | \
grep -v "SecureCRT Config" | \
grep -v "Dropbox" | \
grep -v "GoogleDrive" | \
grep -v "/Volumes/SecureCRT" \

echo "Sorting & removing duplicate entries"
sort -u ${cleaned_tmp} -o "${sorted_and_unique_temp}"

cat "${sorted_and_unique_temp}"
rm "${tmp_file}" "${delete_me}" "${cleaned_tmp}" "${sorted_and_unique_temp}"
echo "Carefully review this list. Copy and paste lines into a terminal to delete."
Reply With Quote