New to the site, please let me know I'm not meeting the post guidelines.
I'm creating a bash script to generate a report with output from a grep command. The goal is to direct
the output to a different log file by using a 'logger file'. But I get this error during the run: $1�: ambiguous redirect.
I'd appreciate if someone can pointout what I'm missing. Thanks.
That's because you are using the unicode U+201C / U+201D (Left / Right Double Quotation Mark) in lieu of the required ascii " (0x22, \o042). The "greater than" sign > thus is unquoted, and interpreted as a redirect operator by the shell.
Is it OK to presume you created the script with a word processor? Try a simple text editor instead.
Thanks guys for the assist. I'v e banging my head on the wall.
Once I updated the "" format to ascii the script worked as needed. Also I noticed after this fix the script works with or without this ... 2>&1. But I will definitely keep this in mind as go onto new tasks.
The second write opens an already opened file. It might get lost when the writing to the stream continues.
Correct is to write to the already opened stream.