🤖
Guides
  • Introduction
  • Beginners
    • Getting Started
  • Guides
    • SQLi Walkthrough
    • My First BoF
    • OSCP Buffer Overflow Guide (Windows)
    • Parrot OS customisation
    • Terminal Customisation
    • Video Guides
  • Cheat Sheets
    • Reverse Shells
    • Tunnelling, Pivoting and Proxies
    • SQL Injection
      • WAF Bypass
      • SQLMap
      • DBMS Cheatsheets
        • MSSQL
        • MySQL
        • Oracle
        • SQLite
        • PostgreSQL
      • References
    • Bash Cheat Sheets
      • Terminal
      • Find
      • Grep
      • Sed
      • Awk
      • Xargs
      • System
      • Download
      • Networking
      • Hardware
      • Variable
      • Math
      • Data Manipulation
      • Random
      • Time
      • Condition and Loop
      • Other
    • OSINT
    • Ping Sweeps
  • Methodologies
    • VOIP Checklist
    • OWASP v4 Checklist
    • External Inf
    • Internal Infrastructure
  • Linux
    • Checklist - Linux Priv Esc
  • Windows
    • Checklist - Windows Priv Esc
  • Things to do/look at
Powered by GitBook
On this page
  • Find
  • List all sub directory/file in the current directory
  • List all files under the current directory
  • List all directories under the current directory
  • Edit all files under current directory (e.g. replace 'www' with 'ww')
  • Find and output only filename (e.g. "mso")
  • Find large files in the system (e.g. >4G)
  • Find and delete file with size less than (e.g. 74 byte)
  • Find empty (0 byte) files
  • Recursively count all the files in a directory

Was this helpful?

  1. Cheat Sheets
  2. Bash Cheat Sheets

Find

Find

List all sub directory/file in the current directory

find .

List all files under the current directory

find . -type f

List all directories under the current directory

find . -type d

Edit all files under current directory (e.g. replace 'www' with 'ww')

find . -name '*.php' -exec sed -i 's/www/w/g' {} \;

# if there are no subdirectory
replace "www" "w" -- *
# a space before *

Find and output only filename (e.g. "mso")

find mso*/ -name M* -printf "%f\n"

Find large files in the system (e.g. >4G)

find / -type f -size +4G

Find and delete file with size less than (e.g. 74 byte)

find . -name "*.mso" -size -74c -delete

# M for MB, etc

Find empty (0 byte) files

find . -type f -empty
# to further delete all the empty files
find . -type f -empty -delete

Recursively count all the files in a directory

find . -type f | wc -l
PreviousTerminalNextGrep

Last updated 4 years ago

Was this helpful?