Why doesn't echo "text" 'command' "more text" work?

Why doesn't echo "text" 'command' "more text" work?

Post by Dave Miel » Wed, 24 Mar 1993 08:05:26




>I want the computer to tell me how many messages I have in my mailbox
>when I log on.  I wanted to put something like this into my .login
>file but It gives me error messages:

>echo "You have" 'grep Subject: /usr/spool/mail/me | wc -l' "messages."

                 ^                                        ^
Wrong quotes, should be -
   echo "You have" `grep Subject: /usr/spool/mail/me | wc -l` "messages."
or -
   echo "You have `grep Subject: /usr/spool/mail/me | wc -l` messages."

But, another problem is, if you've no mail, /usr/spool/mail/me does not
exist, leading grep to say:
   grep: can't open /usr/spool/mail/me
Wc will still report 0.

You might try -
   sh -c 'echo "You have `grep 2>/dev/null Subject: /usr/spool/mail/me | wc -l` messages."'

Hope this helps.

Quote:>Stacy