Zimm3r
Zimm3r

Reputation: 3425

Diffing two variables in a shell script

I have a shell script that has the following line

diff <(echo "$var_1") <(echo "$var_2")

both variables could contain new lines so there, at least from my own understanding, must be "" around the echo statements. However no matter if I escape the "s or not bash continues to say there is an error.

/cygdrive/c/foo/compare_dirs.sh: line 15: syntax error near unexpected token `('
/cygdrive/c/foo/compare_dirs.sh: line 15: `diff <(echo "$var_1") <(echo "$var_2")'

However if I paste that line into cygwin it works?!???!!

Upvotes: 0

Views: 68

Answers (1)

chrisaycock
chrisaycock

Reputation: 37928

As pointed-out in the comments (hat tip to @anubhava), the OP isn't using bash for the actual script. The shebang must be

#!/bin/bash

to use the correct shell.

Upvotes: 2

Related Questions