On Sunday, August 6, 2023 12:28:26 P.M. AEST Walter Dnes wrote:
>   I have a situation where something that works as a literal but
> doesn't work when reading from a text file.  Here's the problem,
> simplified...
> 
>   I have a text file ztest.txt consisting of one line...
> 
> "August 14, 2021"
> 
>   ...and I have a script ztest consisting of...
> 
> #!/bin/bash
> xtoday=$( date --date="August 14, 2021" +%F )
> echo ${xtoday}
> read < ztest.txt
> echo "${REPLY}"
> xtoday=$( date --date="${REPLY}" +%F )
> echo ${xtoday}
> 
>   Running the script produces three lines of output...
> 
> 2021-08-14
> "August 14, 2021"
> date: invalid date ‘"August 14, 2021"’
> 
>   What am I doing wrong?

The date in the text file shoudn't have the quotes around it.

-- 
Reverend Paul Colquhoun, ULC.     http://andor.dropbear.id.au/
  Asking for technical help in newsgroups?  Read this first:
     http://catb.org/~esr/faqs/smart-questions.html#intro




Reply via email to