Last active
October 31, 2022 06:55
-
-
Save elijahscherz/5be8c74a02138f3a2bb1777c66961a5c to your computer and use it in GitHub Desktop.
Quick filename and grep search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -Eeuo pipefail | |
echo | |
# File name search | |
echo -e "\e[36m|------ SEARCHING THROUGH FILE NAMES ------|\e[0m" | |
find . -name "*$1*" | |
echo | |
# Grep content search | |
echo -e "\e[36m|------ SEARCHING THROUGH FILE CONTENTS ------|\e[0m" | |
grepoutput=$(grep -r -n --color=always "$1" .) | |
awk -F: '{OFS = ":"; printf $1 "\n" $2; $1=$2=""; printf $0 "\n\n"}' <<< $grepoutput |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment