以下在命令提示符下按预期工作。 但它不能从cron工作。
# echo "test abc xyz" | grep "test1 \| pqr" # echo "test abc xyz" | grep "test \| pqr" test abc xyz
当我在cron中使用这个语句时,我需要转义某些字符。 但我无法弄清楚。
当我试图把它放在cron中时,我没有看到任何问题。 你是否尝试像下面这样做:
[sgeorge@sgeorge-ld ~]$ crontab -l [email protected] * * * * * /bin/echo "test abc xyz" | grep "test \| pqr" >> stack * * * * * /bin/echo "test abc xyz" | grep "test1 \| pqr" >> stack_with_1 [sgeorge@sgeorge-ld ~]$ ls -l stack* -rw-r--r-- 1 sgeorge eng 13 Jan 11 02:45 stack -rw-r--r-- 1 sgeorge eng 0 Jan 11 02:45 stack_with_1 [sgeorge@sgeorge-ld ~]$ cat stack_with_1 [sgeorge@sgeorge-ld ~]$ cat stack test abc xyz