Wrathchild
Technical User
Hi, I have a couple questions on using variables in scripts.
1. Can I have a command such as grep within a variable like below, or is the grep being executed as the variable is being set? If it's being executed then I can just pull it out and add it to the second line.
2. I can't figure out how to escape the date correctly; I assume it needs to be as the entire line is enclosed within the ` character
LOGCONTENTS=`grep \`date +%Y-%m-%d\` | grep -i "[n][0-9][0-9][0-9][0-9][0-9][0-9][0-9]"`
cat /tmp/logs | ${LOGCONTENTS} > /tmp/test
thanks!
1. Can I have a command such as grep within a variable like below, or is the grep being executed as the variable is being set? If it's being executed then I can just pull it out and add it to the second line.
2. I can't figure out how to escape the date correctly; I assume it needs to be as the entire line is enclosed within the ` character
LOGCONTENTS=`grep \`date +%Y-%m-%d\` | grep -i "[n][0-9][0-9][0-9][0-9][0-9][0-9][0-9]"`
cat /tmp/logs | ${LOGCONTENTS} > /tmp/test
thanks!