Find
·1 min
The find
command is handy tool to manage files inside the file system, the command structure is:
find dir criteria [action]
Where:
dir
is the starting dircriteria
is a filter for the element that have to matchaction
is the action to perform on the elements that matches thecriteria
Limit file search #
In order to limit the depth level of the search the -maxdepth
option can be used
find dir -maxdepth <VALUE> criteria [action]
Oneliners #
- remove files only in current dir with confirmation
find . -maxdepth 1 -type f -exec rm -i {} \;
- exclude elements by regex
find . -not -regex 'REGEX'
- filter by element name
find . -name 'REGEX'