Short questing, why does this line
sed -i '1s/^/#!\/usr\/bin\/env node\n/' tsunit.js;\
Give me this error
sed: 1: "tsunit.js": undefined label 'sunit.js'
in a Makefile, if relevant.
I’m on a Mac.
According to the Apple man page for sed
, the -i
option takes a required argument specifying the file extension for the backup file. As a result, assuming that you are on a Mac or similar, sed
believes that you intended '1s/^/#!\/usr\/bin\/env node\n/'
to be the file extension of the backup. It then interprets tsunit.js
as a sed
command. the leading t
tells sed to branch to the label sunit.js
which, of course, doesn't exist. Hence the error message.
The solution is:
sed -i '.bak' '1s/^/#!\/usr\/bin\/env node\n/' tsunit.js
Or, if you really do not want a backup:
sed -i '' '1s/^/#!\/usr\/bin\/env node\n/' tsunit.js
Also, it looks like you're inserting a line. sed has more commands than s
sed -i "" '1i\
#!/usr/bin/env node' tsunit.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With