I have
IFS=$'\n' read -d '' -ra files < <(find / -name "*.lproj" ! -iname "En*" ! -name "Base*" -o -name "*@3x.png" -o -name "*@3x.jpg" -o -name "*@3x.3ds" -o -path "/private/var/mobile/Containers/Bundle/Application/*/iTunesArtwork" -o -path "/private/var/mobile/Containers/Bundle/Application/*/*/*[email protected]" -o -name "*~iphone*" ! -path "*/Kik.app/*" ! -path "*/fiverr.app/*" -o -path "/private/var/mobile/Containers/Data/*/*/Library/Caches" -o -path "/private/var/mobile/Documents/Flex/*.dat" -o -path "/private/var/mobile/Containers/Data/*/*/tmp/*" -o -path "/private/var/mobile/Documents/CyDown/*" -o -path "/private/var/db/stash/_.*/Applications/*/*[email protected]" -o -path "/private/var/mobile/Containers/Data/*/*/Library/googleanalytics*" -o -path "/private/var/mobile/Containers/Data/*/*/Library/*FlurryFiles" -o -path "/private/var/mobile/Library/BatteryLife/Archives/*" -o -path "/private/var/tmp/*" -o -path "/private/var/lib/apt/lists/partial/*" -o -path "/private/var/mobile/Library/Logs/*" -o -path "/private/var/logs/*" -o -path "/private/var/root/.bash_history" -o -path "/private/var/mobile/Library/googleanalytics*" -o -path "/private/var/mobile/Library/Logs/CrashReporter/DiagnosticLogs/*" -o -path "/private/var/mobile/Library/Caches/*" ! -name "libactivator.plist" -o -iname "*.log" -o -iname "*.old" -o -iname "*.tmp")
du -hc "${files[@]}" 2>/dev/null | tail -1
rm -r "${files[@]}" >/dev/null 2>&1
And
find / -path "/path/to/location" -name '*@2x.png' | sed 's/@2x//' | xargs rm
The first one finds files with names and paths specified, counts the total size, then removes them. The second one finds all files ending in "@2x.png" then tries to remove "@2x.png" from the end and then delete the file.
So how might I combine these two commands into one find?
NOTE: there are direct paths and names (in the first command) that end in "@2x.png" that I do not want remove the "@2x.png" from. So I can't just combine them together. e.g (if they were just combined together) having [email protected]
in the first command (meaning I would want to remove that exact name) would mean sed would remove the "@2x", which is not what I want to do.
Because I'm bad at explaining things: everything in the first command should have the exact name/path specified, and should not be modified by sed. Everything in the second command should be modified by sed, but I want to run only one find command for both.
Not positive I understand what you're trying to do, but if you still want the array to contain the same things in the first command, but the files from the second
find / \( -name "*.lproj" ... -iname "*.tmp" \) -print -o -path "/path/to/location" -name '*@2x.png' -exec bash -c 'echo rm "${1/\@2x/}"' bash {} \;
Note: Remove echo
above to do actual rm
. Also, note if files match the conditions for addition to the array and deletion, they will be added to the array but not deleted, per -o
being short-circuit, if you want the opposite, replace the order.