Skip to content

Instantly share code, notes, and snippets.

@ryancheley
Created October 13, 2024 15:38
Show Gist options
  • Select an option

  • Save ryancheley/69fa6b75023affd514ba3920477cffa4 to your computer and use it in GitHub Desktop.

Select an option

Save ryancheley/69fa6b75023affd514ba3920477cffa4 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Define the path to search for
SEARCH_PATH="/usr/local/bin"
# Define the files to search within
FILES_TO_CHECK=(
"$HOME/.bash_profile"
"$HOME/.bashrc"
"$HOME/.profile"
"$HOME/.zshrc"
"/etc/profile"
"/etc/paths"
"/etc/bash.bashrc"
)
# Function to check each file
check_file() {
local file=$1
if [ -f "$file" ]; then
echo "Checking $file for '$SEARCH_PATH' additions..."
grep -H "$SEARCH_PATH" "$file" | grep PATH
else
echo "File $file does not exist."
fi
}
# Loop through files and check them
for file in "${FILES_TO_CHECK[@]}"; do
check_file "$file"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment