Sunday, November 1, 2009

Using find to locate files in Linux (Part 1)

Find is a useful command line to locate and search files easily. Some usage includes

Note 1: To find a file (For example *.mp3) and print it to your console
$ find ~ -name *.mp3 -print

Note 2: Finding files that have been modified

$ find $HOME -mtime 0
(-mtime refers to modification since the last 24 hr. The time when the file was modified is divided by 24hr with the remainder removed. )

Note 3: Finding files that have been modified with file name in leading directory removed
$ find ~ -type f -mtime 0

Note 4: To serve for files and make the match case-insensitve
$ find ~ -type f -mtime 0 -iname '*.mp3'

Note 5: Finding permission not owned by you
$ find ~ ! -user ${USER}

No comments: