I want to filter non-commented javascript with sed
and output the line number
Here is the example:
/*!
* jQuery UI 1.8.17
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI
*/(function(a,b){function d(b) {return!a(b).parents().andSelf().filter(f/*!
* jQuery UI Widget 1.8.17
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Widget
*/(function(a,b){if(a.cleanData){var c=a.cleanData;a.cleanData=function(b/*!
* jQuery UI Mouse 1.8.17
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Mouse
*
* Depends:
* jquery.ui.widget.js
*/
Somebody told me to use grep -n
and sed
regex like this:
grep -n "" test.js | sed ':a;$!N;$!ba;s/\/\*[^*]*\*\([^/*][^*]*\*\|\*\)*\///g'
It give me output:
1:(function(a,b){function d(b){return!a(b).parents().andSelf().filter(f(function(a,b){if(a.cleanData){var c=a.cleanData;a.cleanData=function(b
But I want output:
9: (function(a,b){function d(b){return!a(b).parents().andSelf().filter(f
17: (function(a,b){if(a.cleanData){var c=a.cleanData;a.cleanData=function(b
Is there something wrong with the regex?