假设我有一个类似的字符串:
Image.Resolution=1024x768,800x600,640x480,480x360,320x240,240x180,160x120,1280x720
我想使用sed
删除第一部分(Image.Resolution=
),然后用逗号分隔其余部分,以便将所有分辨率放入bash数组中。
我知道如何分两步(两个sed
调用)来执行此操作,例如:
sed 's/Image.Resolution=//g' | sed 's/,/ /g'
。
但是作为一种练习,我想知道是否有一种方法可以一次完成。
先感谢您。
放在;
命令之间:
sed 's/Image.Resolution=//g; s/,/ /g'
来自info sed
:
3 `sed' Programs
****************
A `sed' program consists of one or more `sed' commands, passed in by
one or more of the `-e', `-f', `--expression', and `--file' options, or
the first non-option argument if zero of these options are used. This
document will refer to "the" `sed' script; this is understood to mean
the in-order catenation of all of the SCRIPTs and SCRIPT-FILEs passed
in.
Commands within a SCRIPT or SCRIPT-FILE can be separated by
semicolons (`;') or newlines (ASCII 10). Some commands, due to their
syntax, cannot be followed by semicolons working as command separators
and thus should be terminated with newlines or be placed at the end of
a SCRIPT or SCRIPT-FILE. Commands can also be preceded with optional
non-significant whitespace characters.
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句