Problem assigning output to variable when using backticks and reading from STDIN
From: bernd (bew_ba_at_gmx.net)
Date: 11/29/05
- Previous message: Michael Tosch: "Re: sed converting tcsh to bash"
- Next in thread: Michael Tosch: "Re: Problem assigning output to variable when using backticks and reading from STDIN"
- Reply: Michael Tosch: "Re: Problem assigning output to variable when using backticks and reading from STDIN"
- Reply: danr: "Re: Problem assigning output to variable when using backticks and reading from STDIN"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 29 Nov 2005 10:02:57 -0800
Hello folks,
the following is intended to check whether the loaded crontab is
identical to the file stored on hard disk:
> ls
crontab test1.txt test2.txt
> crontab -l | diff crontab -
13c13
< 0,5,10,15,20,25,35,40,45,50,55 0,5-23 * * * $HOME/hellow.ksh
--- > #0,5,10,15,20,25,35,40,45,50,55 0,5-23 * * * $HOME/hellow.ksh So far, so good. As soon as I try to capture the result in a variable using backticks things turn out to be strange: > diffs=`crontab -l | diff crontab -` > echo $diffs 13c13 < 0,5,10,15,20,25,35,40,45,50,55 0,5-23 crontab test1.txt test2.txt crontab test1.txt test2.txt crontab test1.txt test2.txt $HOME/hellow.ksh--- > #0,5,10,15,20,25,35,40,45,50,550,5-23 crontab test1.txt test2.txt crontab test1.txt test2.txt crontab test1.txt test2.txt $HOME/hellow.ksh The variable $diff contains the output in one line, the content of the current directory interspersed into this line. Does somebody know the reason for this strange behaviour and a workaround ? The last command line is intended to work in a shell script and I need the return code of the diff, so I cannot do something like: crontab -l | diff crontab - | while read line do ... Any help appreciated. Cheers Bernd
- Previous message: Michael Tosch: "Re: sed converting tcsh to bash"
- Next in thread: Michael Tosch: "Re: Problem assigning output to variable when using backticks and reading from STDIN"
- Reply: Michael Tosch: "Re: Problem assigning output to variable when using backticks and reading from STDIN"
- Reply: danr: "Re: Problem assigning output to variable when using backticks and reading from STDIN"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]