11

I have this:

cat <<EOF

'use strict';

exports.default = {

  'display names': {}

}

EOF >  "$PWD/tmp.js"

but this is syntactically wrong apparently, anybody know the syntax to do this?

3

1 Answer 1

18
cat <<EOF > "$PWD/tmp.js"
'use strict';
exports.default = {
  'display names': {}
}
EOF

The here-doc redirection operator (<<EOF) is just like other redirection operators, it doesn't end the command. The here-doc itself starts on the following line.

You could also write that first line as cat > "$PWD/tmp.js" <<EOF if that makes it seem more logical.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .