el personaje aparece en los archivos. Cómo eliminarlos?
Estoy comprimiendo archivos JavaScript y el compresor se queja de que mis archivos tienen 
carácter en ellos.
¿Cómo puedo buscar estos caracteres y eliminarlos?
12 answers
perl -pi~ -CSD -e 's/^\x{fffe}//' file1.js path/to/file2.js
Asumiría que la herramienta se romperá si tiene otro utf-8 en sus archivos, pero si no, tal vez esta solución pueda ayudarlo. (No probado ...)
Editar : se agregó la opción -CSD
, según el comentario de tchrist.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-09-05 10:08:02
Puede eliminarlos fácilmente usando vim , aquí están los pasos:
1) En su terminal, abra el archivo usando vim:
vim file_name
2) Eliminar todos los caracteres BOM:
:set nobomb
3) Guarde el archivo:
:wq
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-02-13 21:39:40
Otro método para eliminar esos caracteres-usando Vim :
Nombre de archivo Vim-b
Ahora esos caracteres "ocultos" son visibles (<feff>
) y se pueden eliminar.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-11-13 16:45:12
Gracias por las respuestas anteriores, aquí hay una variante de sed (1) por si acaso:
sed '1s/^\xEF\xBB\xBF//'
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-05-23 08:24:52
En Unix/Linux:
sed 's/\xEF\xBB\xBF//' < inputfile > outputfile
En MacOSX
sed $'s/\xEF\xBB\xBF//' < inputfile > outputfile
Observe el s after sed para mac.
En Windows
Existe Super Sed una versión mejorada de sed. Para Windows este es un standalone .exe, destinado a ejecutarse desde la línea de comandos.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-04-07 11:45:50
Usar cola podría ser más fácil:
tail --bytes=+4 filename > new_filename
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-11-26 05:53:40
La solución de@tripleee no funcionó para mí. Pero cambiar la codificación del archivo a ASCII y nuevamente a UTF-8 hizo el truco: -)
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-10-29 10:16:07
En Windows puedes usar la utilidad backported recode desde UnxUtils.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-04-14 12:22:58
En Sublime Text puede instalar el paquete de resaltadores y luego personalizar la expresión regular en su configuración de usuario.
Aquí agregué \uFEFF
al final de la propiedad highlighter_regex
.
{
"highlighter_enabled": true,
"highlighter_regex": "(\t+ +)|( +\t+)|[\u2026\u2018\u2019\u201c\u201d\u2013\u2014\uFEFF]|[\t ]+$",
"highlighter_scope_name": "invalid",
"highlighter_max_file_size": 1048576,
"highlighter_delay": 3000
}
Para sobrescribir la configuración predeterminada del paquete coloque el archivo aquí:
~/.config / sublime-text-3/Packages/User / highlighter.sublime-ajustes
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-01-09 23:48:02
He usado vimgrep para esto
:vim "[\uFEFF]" *
También comando de búsqueda vim normal
/[\uFEFF]
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-03-10 09:16:20
El comando' file ' muestra si la lista de materiales está presente:
Por ejemplo: 'file myfile.xml 'muestra:" Documento XML 1.0, UTF-8 Unicode (con BOM) texto, con líneas muy largas, con terminadores de línea CRLF"
Dos2unix eliminará la lista de materiales.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-19 14:05:50
Guarde el archivo sin firma de código.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-04-17 15:44:52