Skip to content

Instantly share code, notes, and snippets.

@levensta
Created April 3, 2022 11:54
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save levensta/e2c9ad91e143b249dac9ce3cb4cd8bd3 to your computer and use it in GitHub Desktop.
Save levensta/e2c9ad91e143b249dac9ce3cb4cd8bd3 to your computer and use it in GitHub Desktop.
21-school clearing storage
rm -rf ~/Library/Caches/*
rm -rf ~/Library/42_cache
rm -rf ~/Library/Safari/*
rm -rf ~/.Trash/*
rm -rf ~/.kube/cache/*
rm -rf ~/Library/Containers/com.docker.docker/Data/vms/*
rm -fr ~/Library/Containers/com.apple.Safari/Data/Library/Caches/*
rm -rf ~/Library/Application\ Support/Slack/Cache
rm -rf ~/Library/Application\ Support/Slack/Code\ Cache
rm -rf ~/Library/Application\ Support/Slack/Service\ Worker/CacheStorage
rm -rf ~/Library/Application\ Support/Code/Cache/*
rm -rf ~/Library/Application\ Support/Code/CachedData
rm -rf ~/Library/Application\ Support/Code/CachedExtension
rm -rf ~/Library/Application\ Support/Code/CachedExtensions
rm -rf ~/Library/Application\ Support/Code/CachedExtensionVSIXs
rm -rf ~/Library/Application\ Support/Code/Crashpad/completed
rm -rf ~/Library/Application\ Support/Code/User/workspaceStorage
rm -rf ~/Library/Application\ Support/Firefox/Profiles/*/storage
rm -rf ~/Library/Application\ Support/Telegram\ Desktop/tdata/user_data
rm -rf ~/Library/Application\ Support/Telegram\ Desktop/tdata/emoji
rm -rf ~/Library/Application\ Support/Spotify/PersistentCache
df -h
Полезная команда чтобы обнаружить большие папки/файлы:
du -sh *
Также можно вывести только папки размером свыше 1 gb:
du -sh * | grep -E "\dG"
Команда для отображения текущего свободного выделенного пространства:
df -h
Ищите строку в столбце Mounted on с вашем юзернеймом
Показывает вес скрытых файлов и папок:
du -hs .*[^.*] | sort -h
#!/bin/sh
# Copyright © 2022 Alan Urmancheev <ghelman@student.21-school.ru>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# In the current directory, show paths with size greater than given amount of
# mebibytes (two by default).
minimum=2
test "$#" -gt 0 && {
test "$1" -ge 0 2>/dev/null || exit 1
minimum=$1
}
GLOB='.[!.]* ..?* *'
IFS='
'
set -- $(
IFS=' '
for path in $GLOB; do
[ -e "$path" ] && echo "$path"
done
)
du -sk "$@" 2>/dev/null | sort -rn | awk '{
split("K M G T P", exponents)
significand = $1
i = 1
while (significand >= 1024 && i < length(exponents)) {
significand /= 1024
i++
}
if ($1 >= '$minimum' * 1024) {
$1 = sprintf("%6.1f%s ", significand, exponents[i])
print $0
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment