Find

From KeegansWiki
Revision as of 07:31, 10 January 2019 by Keegan (talk | contribs) (Created page with "=Find in linux= Find all unique file extensions in a folder: find . -type f | awk -F . '{print $NF}' | tr '[:upper:]' '[:lower:]' | sort -u Get file size for all files of pa...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Find in linux

Find all unique file extensions in a folder:

find . -type f | awk -F . '{print $NF}' | tr '[:upper:]' '[:lower:]' | sort -u

Get file size for all files of particular extension:

find . -name "*.txt" | xargs -d '\n' du -sk  > /tmp/sum
cat /tmp/sum | awk -F '\n' '{sum+=$NF} END {print sum}'