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

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