How can I use grep to extract a line from a crontab file and store it to a variable? This is not working:
CTMP=$(crontab -l | grep $SCRIPT)
$SCRIPT is another variable defined within the program. Example anm.sh which is what I am searching for in the crontab to identify the line I need to extract.
Thanks!
* UPDATE *
Its doing something very strange. I tried this:
CTMP=$(crontab -l | grep "anm.sh")
This is what my crontab looks like:
*/17 * * * * cd /home/administrator/anm-1.5.0 && ./anm.sh
However when I echo out CTMP it randomly has a bunch of info that makes no sense. Somehow its pulling the names of directories in the current working directory. Here was the output:
*/17 anm.cfg anm.sh databases logs tmp anm.cfg anm.sh databases logs tmp anm.cfg anm.sh databases logs tmp anm.cfg anm.sh databases logs tmp cd /home/administrator/anm-1.5.0 && ./anm.sh
Those directory names do exist, but why the heck is it pulling those directory names???
All I need to do is get that line from the crontab file stored to the variable CTMP
Thanks