当前位置: 技术问答>linux和unix
sed命令对xml格式配置文件无法处理??
来源: 互联网 发布时间:2017-01-07
本文导语: 本帖最后由 gisupc 于 2011-09-23 11:54:31 编辑 sed命令 对xml文件(UTF-8格式)无法处理 我使用sed -in-place -e 's/10.25.3.107/10.25.3.104/g' 1234.xml就无法修改成功 但是当我把配置文件转换成ANSI格式后, 使用sed -in-place -e 's/10.25.3.1...
我使用sed -in-place -e 's/10.25.3.107/10.25.3.104/g' 1234.xml就无法修改成功
但是当我把配置文件转换成ANSI格式后,
使用sed -in-place -e 's/10.25.3.107/10.25.3.104/g' 1234.txt
运行成功!
我使用的终端是SecureCRT,求高手指点一下,谢谢!
我的xml中配置的ip是类似一下格式
http://10.2.2.2:820/trans
现在要修改成
http://10.2.2.4:820/trans
请问sed命令能实现吗?
|
DESCRIPTION
Sed is a stream editor. A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline). While
in some ways similar to an editor which permits scripted edits (such as ed), sed works by making only one pass over the input(s), and is conse‐
quently more efficient. But it is sed's ability to filter text in a pipeline which particularly distinguishes it from other types of editors.
-n, --quiet, --silent
suppress automatic printing of pattern space
-e script, --expression=script
add the script to the commands to be executed
-f script-file, --file=script-file
add the contents of script-file to the commands to be executed
--follow-symlinks
follow symlinks when processing in place
-i[SUFFIX], --in-place[=SUFFIX]
edit files in place (makes backup if extension supplied)
-l N, --line-length=N
specify the desired line-wrap length for the `l' command
--posix
disable all GNU extensions.
-r, --regexp-extended
use extended regular expressions in the script.
-s, --separate
consider files as separate rather than as a single continuous long stream.
-u, --unbuffered
load minimal amounts of data from the input files and flush the output buffers more often
--help display this help and exit
--version
output version information and exit
If no -e, --expression, -f, or --file option is given, then the first non-option argument is taken as the sed script to interpret. All remaining
arguments are names of input files; if no input files are specified, then the standard input is read.
E-mail bug reports to: bonzini@gnu.org . Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
Sed is a stream editor. A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline). While
in some ways similar to an editor which permits scripted edits (such as ed), sed works by making only one pass over the input(s), and is conse‐
quently more efficient. But it is sed's ability to filter text in a pipeline which particularly distinguishes it from other types of editors.
-n, --quiet, --silent
suppress automatic printing of pattern space
-e script, --expression=script
add the script to the commands to be executed
-f script-file, --file=script-file
add the contents of script-file to the commands to be executed
--follow-symlinks
follow symlinks when processing in place
-i[SUFFIX], --in-place[=SUFFIX]
edit files in place (makes backup if extension supplied)
-l N, --line-length=N
specify the desired line-wrap length for the `l' command
--posix
disable all GNU extensions.
-r, --regexp-extended
use extended regular expressions in the script.
-s, --separate
consider files as separate rather than as a single continuous long stream.
-u, --unbuffered
load minimal amounts of data from the input files and flush the output buffers more often
--help display this help and exit
--version
output version information and exit
If no -e, --expression, -f, or --file option is given, then the first non-option argument is taken as the sed script to interpret. All remaining
arguments are names of input files; if no input files are specified, then the standard input is read.
E-mail bug reports to: bonzini@gnu.org . Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
|
先用iconv命令转换一下格式
|
你是乱撞对的,.在你的表达式当中是对应一个字符,所以你转化为ANSI编码后,就恰好可以处理了。正确的语法是这么写的。utf-8没有这么对应。
sed -in-place -e 's/10.25.3.107/10.25.3.104/g' 1234.xml
无论是什么编码都可以了。
sed -in-place -e 's/10.25.3.107/10.25.3.104/g' 1234.xml
无论是什么编码都可以了。