I'm writing a script that will remove comments from normalize.css which looks like this:
/*! normalize.css v7.0.0 | MIT License | github.com/necolas/normalize.css */
/* Document
========================================================================== */
/**
* 1. Correct the line height in all browsers.
* 2. Prevent adjustments of font size after orientation changes in
* IE on Windows Phone and in iOS.
*/
html {
line-height: 1.15; /* 1 */
-ms-text-size-adjust: 100%; /* 2 */
-webkit-text-size-adjust: 100%; /* 2 */
}
/* Sections
========================================================================== */
/**
* Remove the margin in all browsers (opinionated).
*/
I tried with
#!/usr/bin/env sh
normalize="node_modules/normalize.css/normalize.css"
if [[ -f "$normalize" ]]; then
grep -v "\\/\\*([^*]|[\\r\\n]|(\\*+([^*\\/]|[\\r\\n])))*\\*\\/+" $normalize > index.css
else
echo "There is no normalize.css available."
fi
I have loaded the normalize.css via package.json
{
"devDependencies": {
"normalize.css": "latest"
}
}
You can test this by saving the above package.json in a folder and running npm i. If you have node and npm you should have node_modules folder with normalize in it.
The regex101 finds the comments with above regex, but grep just outputs the same file with comments.
What am I doing wrong?
EDIT: Expected output:
html {
line-height: 1.15;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
sedwould be much better suited for your problem. You could replace everything that matches^\/\**\*\/$with''sedworks line by line, so the regex would have to take every possible case in the account, no?