Herramientas Bash
Busqueda de texto en archivos
#!/bin/bash
usage() { echo "Usage: $0 <search_text> [-H|-l]" echo " -H: Show file names and matching lines (default)" echo " -l: Show only file names" exit 1}
# Set default grep optiongrep_option="-H"
# Check if at least one argument is providedif [ $# -eq 0 ]; then usagefi
# Set the search textsearch_text="$1"shift
# Check for optional parameterif [ "$1" = "-l" ]; then grep_option="-l"elif [ "$1" = "-H" ]; then grep_option="-H"fi
# Perform the searchfind . -type f \( -not -path "*/node_modules/*" -and -not -path "*/.git/*" \) -exec grep $grep_option "$search_text" {} +