tags:

views:

310

answers:

3

Hi,

I get in a bash script, in the follwoing line

 echo $AAAA"     "$DDDD"         "$MOL_TAG  >>  ${OUPUT_RESULTS}

the error:

 line 46: ${OUPUT_RESULTS}: ambiguous redirect

Why?

Thanks

+3  A: 

Do you have a variable named OUPUT_RESULTS or is it the more likely OUTPUT_RESULTS?


michael@isolde:~/junk$ ABC=junk.txt
michael@isolde:~/junk$ echo "Booger" > $ABC
michael@isolde:~/junk$ echo "Booger" >> $ABB
bash: $ABB: ambiguous redirect
michael@isolde:~/junk$ 
JUST MY correct OPINION
sorry, i should drink less coffee, thanks a lot
Werner
A: 

Does the path specified in ${OUPUT_RESULTS} contain any whitespace characters? If so, you may want to consider using ... >> "${OUPUT_RESULTS}" (using quotes).

(You may also want to consider renaming your variable to ${OUTPUT_RESULTS} ;-))

Thomas
A: 

put quotes around your variable. If it happens to have spaces, it will give you "ambiguous redirect" as well. also check your spelling

echo $AAAA"     "$DDDD"         "$MOL_TAG  >>  "${OUPUT_RESULTS}"

eg of ambiguous redirect

$ var="file with spaces"
$ echo $AAAA"     "$DDDD"         "$MOL_TAG >> ${var}
bash: ${var}: ambiguous redirect
$ echo $AAAA"     "$DDDD"         "$MOL_TAG >> "${var}"
$ cat file\ with\ spaces
aaaa     dddd         mol_tag
ghostdog74
Quotes don't matter. If there are spaces in the variable expansion you'll just get things going to the wrong file and/or spurious error messages involving the post-space portion of the file name.
JUST MY correct OPINION
why the downvote!
ghostdog74
@ttmrichter, it DOES matter!
ghostdog74
I stand corrected. Weird, I've never seen that in the past.
JUST MY correct OPINION