Showing posts with label unix. Show all posts
Showing posts with label unix. Show all posts

Wednesday, February 9, 2011

Get folder size on OSX

Haruka had this problem, here is a simple solution
du -sh FOLDER_NAME

du (abbreviated from disk usage) is a standard Unix program used to estimate the file space usage—space used under a particular directory or files on a file system.

Sunday, June 27, 2010

Finding in files

Finding a string in files is useful and not that straightforward. But don't despair, we have bash.

find . -exec grep -q 'foobar' '{}' \; -print

This searches in the current directory including its subdirectories and finds files that contain foobar.

Monday, June 14, 2010

Unix sort by column

Sort is a very useful unix utility. Simplest usage is here::

ls | sort

but that's not very interesting. Let's say we want to sort all the files by size:

ls -l | sort -k5 -n

What this command does exactly sort by 5th field using numeric order. Another useful option you may use is -t which allows you to select the field separator.