I'm looking to write a bash script that recursively searches directories, find a particular string, then opens to that string in that particular file.
I call this function exert because it takes away the exertion of finding a particular variable in my software. For e.g. if my website uses a phrase like "I like big cats" in a div, and I want to edit just that div, I can type "exert 'I like big cats'" and it will open the file holding that div along with the exact spot that div is at.
Here is my code so far:
#!/bin/bash
echo "Searching for $1"
echo "----Inside files----"
grep --color=always  -nr "$1" * > /tmp/tmpsearch; #searches for ' I like big cats'
filesNew=`cat /tmp/tmpsearch` #stores it in a variable that can be split - future version will keep this in memory 
readarray -t files <<<"$filesNew" #it is split to an array called $files
x=0;
IFS=":"; #":" is the string delimter for grep's output of files with the string, alongside the line number the string is found inside the file 
for i in "${files[@]}"; do
    #The colon operator separates grep's output of line numbers and files that contain the string 'I like big cats'
    read -ra FOUND <<< "$i" 
    x=$[$x+1];
    printf "Found index: $x\n"
    line=`echo "${FOUND[1]}"`
    file=`echo "${FOUND[0]}"`
    nano +$line ./$file #This should open nano at the exact line number 
done
exit 1
Everything works fine, but nano seems to be interpreting an encoding error when being called with an array output from a bash script. 
Although the strings are fine inside the bashscript, nano will read a file name like ./app.vue as ./^[[35m^[[Kapp.vue^[[m^[[K^[[36m^[[K. There a lot of command characters around the file name that I can't seem to get rid of.
By placing nano app.vue at the start of the script, which works, I know this isn't a problem with just nano or just bash, but a problem with them working with an array output (the string split from grep) 
