Re: Difference between cat and echo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dan Track wrote:
> Hi
> 
> I've been testing something out in cron, I ran the following:
> 
> MAILTO: user@xxxxxxxxxxx
> * * * * * cat % This is a test message
> * * * * * echo % This is a test message
> 
> When I get my emails, for the cat command, the subject states: "cat "
> and the body states:
> "This is a test message"
> 
> However for the echo command I get "echo " in the subject but the body
> is empty.
> 
> This made me wonder and hence ask you guys, why does cat work in
> outputting the message while echo doesn't?
> 
> Thanks in advance for any help.
> 
> Dan
> 

RTF(riendly)M.  In this case, "man 5 crontab" is an excellent start.  It
says:

The  "sixth"  field  (the rest of the line) specifies the command to be
run.  The entire command portion of the line, up  to  a  newline  or  %
character, will be executed by /bin/sh or by the shell specified in the
SHELL variable of the cronfile.   Percent-signs  (%)  in  the  command,
unless escaped with backslash (\), will be changed into newline
characters, and all data after the first % will be sent  to  the
command  as standard input.

Which means that in your case both cat and echo get that string as
input, but only cat reads from standard input.

-- 
Sjoerd Mullender

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux