scripts icon indicating copy to clipboard operation
scripts copied to clipboard

Make sed commands more robust

Open Nutlope opened this issue 4 years ago • 0 comments

sed -i "" '12,15d' ./index.js

I'd be a bit wary of using hard-coded line numbers. Seems like you could get the same results while being way more future-proof (in case CRA changes in the future) with something like:

sed -substitute

Find final );\n in file ./index.js

Grab it and everything after it.

Replace all of the above with the final );\n

sed -i 's|();\n)[\s\S]*|\1|' ./index.js

Nutlope avatar Jul 09 '21 22:07 Nutlope