How do I make it so from the peptides list it gets all of the text, not just one variable from the ARRAY variable. Is there some sort of delimiter I can use? I want to put a paragraph and have it highlight a database of words, but I can't get it to work.
Textfile:
bad
wait
fu
too
#!/bin/bash
#this is the array how do I make it get all the words not just wait...
ARRAY=(wait bad)
while read line ; do (echo $line | sed ''/$ARRAY/s//`printf "\033[32m$ARRAY\033[0m"`/'' ); done < peptides.txt
This is what I turned it into, yet I cannot seem to get the piping to not exit during the grips. I don't understand the complexity behind it, but this is what I got it working with. I can't get it working without these kazoos on the start of each .db file. I added those so the sed pipes didn't exit. For some reason not finding a match stopped the pipe with some exit code?
kazooa kazoob kazooc kazood kazooe kazoof kazoog kazooh kazooi kazooj kazook kazool kazoom kazooz
#!/bin/bash
set -euo pipefail
#echo "anything" | { grep e || test $? = 1; } | { grep e2 || test $? = 1; }
shopt -s expand_aliases
alias egrep-green=" GREP_COLOR='1;32' grep -E --color=always"
alias egrep-yellow-underline=" GREP_COLOR='4;33' grep -E --color=always"
alias egrep-yellow-highlight=" GREP_COLOR='7;33' grep -E --color=always"
alias egrep-yellow-blinking=" GREP_COLOR='5;33' grep -E --color=always"
alias egrep-yellow-italic=" GREP_COLOR='3;33' grep -E --color=always"
alias egrep-yellow=" GREP_COLOR='1;33' grep -E --color=always"
alias egrep-red=" GREP_COLOR='1;31' grep -E --color=always"
alias egrep-red-highlight=" GREP_COLOR='7;31' grep -E --color=always"
alias egrep-red-blinking=" GREP_COLOR='5;31' grep -E --color=always"
alias egrep-blue-italic=" GREP_COLOR='3;34' grep -E --color=always"
alias egrep-cyan-italic=" GREP_COLOR='3;36' grep -E --color=always"
alias egrep-magenta-italic=" GREP_COLOR='3;35' grep -E --color=always"
#kaplan traffic light system
#kaplan light yellow
#slow down most to least
#comparison most
#contrast middle
#opposition middle
#sequences least yellow
#yellow/red authorkeywords
#kaplan go green
#continuation
#kaplan stop red
#evidence
#conclusion
#refutation
#&& { echo $?; echo Found ;} || { echo $?; echo Not found ;}
clear;
echo "continuation" | egrep-green continuation; echo "evidence" | egrep-red-highlight evidence; echo "conclusion" | egrep-red conclusion; echo "refutation" | egrep-red-blinking refutation; echo "comparison" | egrep-yellow-highlight comparison; \
echo "contrast"| egrep-yellow-underline contrast; echo "opposition" | egrep-yellow-underline opposition; echo "sequence" | egrep-yellow sequence; echo "positive" | egrep-yellow-italic positive; echo "negative" | egrep-blue-italic negative; \
echo "extreme" | egrep-cyan-italic extreme; echo "moderating" | egrep-magenta-italic moderating; \
cat frog.txt | egrep-green -z -w -f continuation.db \
| egrep-red-highlight -z -w -f evidence.db \
| egrep-red -z -w -f conclusion.db \
| egrep-red-blinking -z -w -f refutation.db \
| egrep-yellow-highlight -z -w -f comparison.db \
| egrep-yellow-underline -z -w -f contrast.db \
| egrep-yellow-underline -z -w -f opposition.db \
| egrep-yellow -z -w -f sequence.db \
| egrep-yellow-italic -z -w -f positive.db \
| egrep-blue-italic -z -w -f negative.db \
| egrep-cyan-italic -z -w -f extreme.db \
| egrep-magenta-italic -z -w -f moderating.db \
| fold -w 240 -s \
#continuation.db
#contrast.db
#opposition.db
#sequence.db
#comparison.db
#conclusion.db
#refutation.db
#evidence.db
#positive.db
#negative.db
#extreme.db
#moderating.db




for word in "${ARRAY[@]}"sed -r 's/bad|wait/\033[32m&\033[0m/.&is replaced with whatever matched the regexp.tooto match onmetooortools?grep-based answerssedcan work on an entire file so for this particular example there's no need to use awhile readloop to process lines one at a time; you could replace the entirewhile readloop with the more efficientsed 'your-final-sed-script' peptides.txt; also in this case the repeated(echo ... | sed ...)requires spawning two new subshells for each pass through the loop, while a singlesed 'your-final-sed-script' peptides.txtwill spawn no subshells (for any appreciably sized file you should notice a huge improvement in performance)