UNIX-1.7 Find Command


Make sure to subscribe to my channel for more videos on UNIX, Perl and SQL.
facebook: facebook.com/fuzicast
twitter: @fuzicast
youtube: youtube.com/yuejdesigner85

find . -iname ‘regex’ – find filenames that match regex, case insensitive
find . -mtime +2 – find files that were modified 2 days ago or older
find . -mtime -2 – find files that were modified within past 2 days
find . -ctime +2 – find files that were created 2 days or older
find . -atime +2 – find files that were accessed 2 days or older
find . -cmin +30 – find files that were created 30 minutes ago or older
find . -mmin +30 – find files that were modified 30 minutes ago or older
find . -empty – find empty files or directory
find . -executable – find files that are executable by user
find . -readable – find files that are readable by user
find . -writable – find files that are writable by user
find . -size filesize – find files that have specified filesize (c = byte, k = kb, M = Mb, G = Gb)
find . -type filetype – find by file type (d = directory, f = file, l = link)
find . -user username – find files owned by user
find . -group groupname – find files that belong to specific group
find . -name ‘regex’ -delete – remove files that match regex
find . -name ‘regex’ -exec command – execute command on files found
find . -name ‘regex’ -ok command – same as -exec, but prompts for user’s input

Advertisements

Regex-1.1 Regular Expression Introduction


Make sure to subscribe to my channel for more videos on UNIX, Perl and SQL.
facebook: facebook.com/fuzicast
twitter: @fuzicast
youtube: youtube.com/yuejdesigner85

\w – matches a alphanumeric character
\d – matches a number
\s – matches a space
\W, \D, \S – opposite of \w, \d, \s
^ – beginning of line
$ – end of line character
. – match any character except for newline
* – 0 or more occurrence
+ – 1 or more occurrence
? – 0 or 1 occurrence
| – alternative match
(regex) – grouping/store match
[ ] – character set/class
{ x,y } – number of occurrence between x and y
{ x } – x occurrence
{ x, } – at least x occurrence
[^ ] – opposite of [ ]
*? – non greedy matching