Main Options
Try searching and processing files within the file system by combining the various options of the `find` command.
1. Basic Search
2. Time Conditions
3. Size and Permission Conditions
4. Actions
Generated command:
Try combining the commands.
Description:
`find` Executes the command.
Combine the above options to virtually execute commands with AI.
Logical Operators
The `find` command provides logical operators to perform more precise searches by combining multiple conditions.
Operator | Description | Example |
---|---|---|
-and (or omitted) | When both the left and right conditions are true | `find . -name "*.txt" -and -size +1M` |
-or | When at least one of the left or right conditions is true | `find . -name "*.log" -or -name "*.tmp"` |
-not (or !) | When the condition is false | `find . -not -name "*.txt"` |
( ) | Grouping conditions (requires escaping) | `find . \( -name "*.txt" -or -name "*.doc" \)` |
Operator Precedence
The operators of the `find` command are generally evaluated so that actions are processed after expressions. Within conditions, parentheses (`( )`) can be used to explicitly specify precedence. When using parentheses, they must be escaped with a backslash (`\`) as they have special meaning in the shell.
Usage Examples
Practice file searching and management through practical usage examples of the `find` command.
Find all files with the '.log' extension in the current directory
find . -name "*.log"
Searches for all files ending with `.log` in the current location.
Find files larger than 50MB
find /var -size +50M
Searches for all files exceeding 50MB in size under the `/var` directory of the system.
Find 'conf' files modified within the last 7 days
find . -name "*.conf" -mtime -7
Finds `.conf` files modified within the last 7 days in the current directory.
Find all directories with access permission 777
find / -type d -perm 777
Searches for directories with permissions set to 777 across the entire system to check for security risks.
Delete old '.tmp' files
find /tmp -name "*.tmp" -mtime +30 -delete
Finds and deletes all `.tmp` files older than 30 days in the `/tmp` directory.
Execute a specific command on found files (chmod)
find . -name "*.sh" -exec chmod 755 {} \;
Grants execute permissions (755) to all files with the `.sh` extension in the current directory.
Find files larger than 1GB owned by a specific user
find /home -user user1 -size +1G
Searches for files in the `/home` directory that are owned by `user1` and are larger than 1GB.