From 02427ad9829e33087fb1ac79355041f12fa4e7c3 Mon Sep 17 00:00:00 2001 From: Samuel Koprivnjak Date: Sun, 26 May 2019 18:08:25 +0200 Subject: [PATCH] Linux find cmd examples (#29360) * Useful find commands examples * Update index.md --- .../linux/using-the-find-command/index.md | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/guide/english/linux/using-the-find-command/index.md b/guide/english/linux/using-the-find-command/index.md index 226267379d..683edcf84a 100644 --- a/guide/english/linux/using-the-find-command/index.md +++ b/guide/english/linux/using-the-find-command/index.md @@ -27,3 +27,30 @@ Other parameters are optional and can be combined in any way you find useful: * The name parameter lets you specify what you want to find by name, either with a literal string ('filename.txt') or using wildcards ('file?.*'). `man find` will show you many more parameters, and is worth reviewing. Find can locate files by name, user, creation date, size and much more. Next time you're looking for something, find it! + +## Useful find commands +### Find all javascript files +```bash +find . -type f -name "*.js" +./server.php +./model.js +./config.js +``` + +### Find and remove multiple files +To find and remove multiple files such as .txt, then use. +```bash +find . -type f -name "*.txt" -exec rm -f {} \; +``` + +### Find last 30 days modified files +To find all the files which are modified 30 days back. +```bash +find / -mtime 30 +``` + +### Find files with size between 100MB – 200MB +To find all the files which are greater than 100MB and less than 200MB. +```bash +find / -size +100M -size -200M +```