Skip to content

Instantly share code, notes, and snippets.

@mishudark
Created November 13, 2010 22:48
Show Gist options
  • Save mishudark/675718 to your computer and use it in GitHub Desktop.
Save mishudark/675718 to your computer and use it in GitHub Desktop.
Elimina todos los comentarios (no usar con js comprimido tipo jquery.min.js
#!/bin/bash
#mishudark <[email protected]> <[email protected]>
#thanks ostermiller.org to amazing regex
#
# delete_comments.sh
#
# Copyright 2010 mishudark <[email protected]> <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
if [ -z $1 ]
then
echo "Debe ingresar el nombre de un archivo valido"
exit 1
else
archivo=$1
perl -pi -0777ne 's/\/\*(?:.|[\r\n])*?\*\///g;' $archivo
perl -pi -e 's/\/\/.*//g' $archivo
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment