32 lines
772 B
Bash
Executable File
32 lines
772 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Check if the correct number of arguments is provided
|
|
if [ "$#" -lt 1 ]; then
|
|
echo "Usage: $0 search_string"
|
|
exit 1
|
|
fi
|
|
|
|
# Assign the first argument to the search_string variable
|
|
search_string="$1"
|
|
|
|
# Define the directories to exclude (modify these as needed)
|
|
exclude_dirs=("IPMT10" "IPMT7" "RACKMOUNT126" "RACKMOUNT88" "WALLMOUNT28")
|
|
|
|
# Define the fixed file extensions
|
|
extensions=("java" "xml" "h")
|
|
|
|
# Build the include options for grep
|
|
include_opts=""
|
|
for ext in "${extensions[@]}"; do
|
|
include_opts+="--include=*.$ext "
|
|
done
|
|
|
|
# Build the exclude options for grep
|
|
exclude_opts=""
|
|
for dir in "${exclude_dirs[@]}"; do
|
|
exclude_opts+="--exclude-dir=$dir "
|
|
done
|
|
|
|
# Perform the grep search
|
|
grep -rn $exclude_opts $include_opts -i "$search_string"
|