lazyhacker 2 years ago

find command CheatSheet

Basic Examples:

# Search for files or directories with the exact name "example.txt" in the current directory (and its subdirectories).

find . -name "example.txt"   

# Find all directories in the "/home" directory.     

find /home -type d 

# Search for files owned by the user "john" in the "/data" directory.           

find /data -user john  

# Find all files with the extension ".txt" in the current directory and download them using `curl`.          

find . -type f -name "*.txt" -exec curl -O {} \; 

Intermediate Examples:

# Extract specific content from a webpage using `curl` and `sed`.

curl https://example.com/page.html | sed -n 's/<p>\(.*\)<\/p>/\1/p'  

# Find all directories in the "/home" directory and count the number of files in each using `find` and `wc`.

find /home -type d -exec sh -c 'echo -n "{}: "; find "{}" -type f | wc -l' \; 

# Find all files modified in the last 7 days and perform an HTTP POST request with their content using `find`, `curl`, and `xargs`.

find . -type f -mtime -7 -print0 | xargs -0 -I{} curl -X POST -d @{} https://api.example.com/upload 

# Search for files with the extension ".log" in the "/var/logs" directory, compress them, and store in a backup folder using `find`, `curl`, and `tar`.

find /var/logs -type f -name "*.log" -exec tar czvf /backup/logs_backup.tar.gz {} \;  

Advanced Examples:

# Find all files in the current directory larger than 10MB and delete them using `find` and `rm`.

find . -type f -size +10M -exec rm {} \; 


0
3.2K
HTB CAPE Preparation Guide: A Detailed Roadmap for Success

HTB CAPE Preparation Guide: A Detailed Roadmap for Success

defaultuser.png
lazyhacker
2 months ago
Administrator HTB Writeup | HacktheBox

Administrator HTB Writeup | HacktheBox

defaultuser.png
lazyhacker
10 months ago
A very comprehensive penetration testing memo

A very comprehensive penetration testing memo

defaultuser.png
lazyhacker
2 years ago
Introduction to APIs: A Comprehensive Guide to Understanding Their Purpose and Applications

Introduction to APIs: A Comprehensive Guide to Understanding Their Pur...

defaultuser.png
X0NE
2 years ago

CS cybersecurity crisis

defaultuser.png
Kend
2 years ago