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?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communitycat <<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.
cat <<EOF > "$PWD/tmp.js"
... lines ...EOF
.