I have a script that repeats the same (very long) grep command many times. I want to make the script more readable by cutting the line length, so I tried to put parts of the command into variables.This is the line (that repeats many times in the script, with different parameters):rsync -av --delete -R --exclude=alternatives /etc/ /backup.raw/ | grep -E '^deleting|[^/]$' >> /var/log/rsync.logThat line works ok. What I did trying to abbreviate it, is:_rscmd='rsync -av --delete -R'_mn=/backup.raw/_grep='grep -E ^deleting|[^/]$'_rslog=/var/log/rsync.logso the final line could be:$_rscmd --exclude=alternatives /etc/ $_mn | $_grep >> $_rslogBut that line fails on the $_grep variable. How can I write it right? I tried to use  and '', with no luck. Pay attention to the original grep command that works, please.
Split command and arguments, and put into variable in a bash script
bash;scripting;grep;variable
The splitting into different parts (command & arguments) does not work ifvariables are used. Use eval for this case:eval $_rscmd --exclude=alternatives /etc/ $_mn | eval $_grep >> $_rslogIn general, it is better to use shell functions or aliasesthan using variables:alias my_grep='grep -E ^deleting|[^/]$'...... | my_grep >> $_rslog