Skip to content

Instantly share code, notes, and snippets.

@Busyrev
Last active April 10, 2025 21:37
Show Gist options
  • Save Busyrev/1e41c58ad081cf861c167eee3f554ea9 to your computer and use it in GitHub Desktop.
Save Busyrev/1e41c58ad081cf861c167eee3f554ea9 to your computer and use it in GitHub Desktop.
Хинты для работы с *nix command line

Суммарный вес png в мегабайтах, рекурсивно
find . -type f -iname \*.png -ls | awk '{a+=$7}END{print a/1024/1024}'
Суммарная площадь png в мегапикселях, рекурсивно
find . -type f -iname \*.png | xargs file | awk '{a+=$5*$7}END{print a/1024/1024}'
Количество png, рекурсивно
find . -type f -iname \*.png | wc -l
Скопировать все png в отдельное место, рекурсивно
find . -type f -iname "*.png" -exec cp {} ./pngs \;
выбрать самый большой png по размеру
find . -type f -iname \*.png -printf "%s\t%p\n" | sort -n | tail -1
Конкатенировать текстовые файлы, рекурсивно
find . -type f -iname \*.eee | perl -e 'print "["; my @a; while(<>){ local $/ = undef; open my $fh, "< $_"; push(@a, <$fh>);} print join(",", @a) . "]"' > meta.json
Используя xargs просунуть переданное значение в несколько мест
echo a b c | xargs -n1 -I% echo %.zzz %.asdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment