Unix Shell - Re: Problem assigning output to variable when using backticks and

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > November 2005 > Re: Problem assigning output to variable when using backticks and





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: Problem assigning output to variable when using backticks and
Michael Tosch

2005-11-29, 5:58 pm

bernd wrote:
> Hello folks,
>
> the following is intended to check whether the loaded crontab is
> identical to the file stored on hard disk:
>
>
>
> crontab test1.txt test2.txt
>
>
> 13c13
> < 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:
>
>
>
> 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 diffs variable is correct. The problem occurs when the shell
parses the unquoted $diffs.

echo "$diffs"

and the shell treats the $diffs as a string.

--
Michael Tosch @ hp : com
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com