分页: 1 / 1

sed 's/.*\(.\)$/\1/' 与 sed 's/.*\///g'都是什么意思

发表于 : 2009-11-17 12:11
yangstone
这两个都包含一个.*,我不明白是什么意思,还有就是$应该表示是末尾吧,希望哪位可以详细的解释一下这个两个表达式

Re: sed 's/.*\(.\)$/\1/' 与 sed 's/.*\///g'都是什么意思

发表于 : 2009-11-17 12:23
mrdenglazy
.*是表示匹配所有,$在这里是行未
第一个意思是把所有以.结尾的行,都替换为.
第二个意思是所有包含V的行,删除这些行V以前包括V在内的字符

Re: sed 's/.*\(.\)$/\1/' 与 sed 's/.*\///g'都是什么意思

发表于 : 2009-11-17 12:32
xjpvictor
V?

Re: sed 's/.*\(.\)$/\1/' 与 sed 's/.*\///g'都是什么意思

发表于 : 2009-11-17 12:37
nmsfan
正则表达式?还看不懂 :em06 :em06

Re: sed 's/.*\(.\)$/\1/' 与 sed 's/.*\///g'都是什么意思

发表于 : 2009-11-17 12:42
yangstone
不是V 是\+/。。。。。

Re: sed 's/.*\(.\)$/\1/' 与 sed 's/.*\///g'都是什么意思

发表于 : 2009-11-17 12:44
eexpress
:em04 V

Re: sed 's/.*\(.\)$/\1/' 与 sed 's/.*\///g'都是什么意思

发表于 : 2009-11-17 12:45
pityonline
xjpvictor 写了:V?
好像是"\"和"/"……

这句型有点儿像rename后面的,这些东西蛮有意思的,但我不知道具体定义是什么,还得学习啊……

Re: sed 's/.*\(.\)$/\1/' 与 sed 's/.*\///g'都是什么意思

发表于 : 2009-11-17 12:49
eexpress

代码: 全选

● cat ansi2html.bash 
#!/bin/bash

# Convert ANSI (terminal) colour codes to HTML
# Last Modify: eexpress @ 2009-02-27
# Author:
#    http://www.pixelbeat.org/docs/terminal_colours/

echo -n "
<head>
<style type=\"text/css\">
/* linux console palette */
.f0 { color: #000000; }
.f1 { color: #FF0000; }
.f2 { color: #00AA00; }
.f3 { color: #E5E414; }
.f4 { color: #5B5BFC; }
.f5 { color: #FF00FF; }
.f6 { color: #01FEFD; }
.f7 { color: #AAAAAA; }
.bf0 { color: #555555; }
.bf1 { color: #FF5555; }
.bf2 { color: #55FF55; }
.bf3 { color: #FFFF55; }
.bf4 { color: #5555FF; }
.bf5 { color: #FF55FF; }
.bf6 { color: #55FFFF; }
.bf7 { color: #FFFFFF; }
.b0 { background-color: #000000; }
.b1 { background-color: #AA0000; }
.b2 { background-color: #00AA00; }
.b3 { background-color: #CDCD00; }
.b4 { background-color: #0000AA; }
.b5 { background-color: #AA00AA; }
.b6 { background-color: #00AAAA; }
.b7 { background-color: #E5E5E5; }
.bold { font-weight:bold; }
.normal { font-weight:normal; color: #AAAAAA; background-color: #000000; }
.reverse { background-color: #2A2A2A; }
.underline { text-decoration: underline; }
.line-through { text-decoration: line-through; }
.blink { text-decoration: blink; }
</style>
<title>xterm ansi color screenshot -> html</title>
</head>
<html>
<body bgcolor=\"#000000\" text=\"#ffffff\">
<pre>
"
#<meta content="charset=UTF-8">
#<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
#<meta http-equiv="content-type" content="text/html; charset=UTF-8">
p='↗[^↖]*\<'
e='\>[^↖]*'
echo '<span>'
sed 's/\xef\xbf\xbf//g'|\
sed 's#\&#\&#g; s#>#\>#g; s#<#\<#g'|\
#sed 's#\"#\"#g; s#\ +#\&nbsp;#g'|\
sed 's#\x1b\#[0-9]##g'|\
#sed 's#\x1b\[0m##g'|\
sed 's#\x1b\[\([0-9;]*\)m#↗\1↖#g'|\
sed "s#${p}1${e}#& bold#g"|\
sed "s#${p}4${e}#& underline#g"|\
sed "s#${p}5${e}#& blink#g"|\
sed "s#${p}7${e}#& reverse#g"|\
sed "s#${p}9${e}#& line-through#g"|\
sed "s#${p}3\([0-7]\)${e}#& f\1#g"|\
sed "s#${p}4\([0-7]\)${e}#& b\1#g"|\
#sed "s#↗0↖##g"|\
sed "s#↗[0-9;\ ]\+#</span><span class=\"#g"|\
sed "s#↖#\">#g"|\
#sed "s#^#</span><span class=\"normal\">#g"|\
tr -d "\r"|\
cat
echo '</span>'

echo "</pre>
</body>
</html>
"
来研究这个吧

Re: sed 's/.*\(.\)$/\1/' 与 sed 's/.*\///g'都是什么意思

发表于 : 2009-11-17 14:14
引火虫
eexpress 写了:

代码: 全选

● cat ansi2html.bash 
#!/bin/bash

# Convert ANSI (terminal) colour codes to HTML
# Last Modify: eexpress @ 2009-02-27
# Author:
#    http://www.pixelbeat.org/docs/terminal_colours/

echo -n "
<head>
<style type=\"text/css\">
/* linux console palette */
.f0 { color: #000000; }
.f1 { color: #FF0000; }
.f2 { color: #00AA00; }
.f3 { color: #E5E414; }
.f4 { color: #5B5BFC; }
.f5 { color: #FF00FF; }
.f6 { color: #01FEFD; }
.f7 { color: #AAAAAA; }
.bf0 { color: #555555; }
.bf1 { color: #FF5555; }
.bf2 { color: #55FF55; }
.bf3 { color: #FFFF55; }
.bf4 { color: #5555FF; }
.bf5 { color: #FF55FF; }
.bf6 { color: #55FFFF; }
.bf7 { color: #FFFFFF; }
.b0 { background-color: #000000; }
.b1 { background-color: #AA0000; }
.b2 { background-color: #00AA00; }
.b3 { background-color: #CDCD00; }
.b4 { background-color: #0000AA; }
.b5 { background-color: #AA00AA; }
.b6 { background-color: #00AAAA; }
.b7 { background-color: #E5E5E5; }
.bold { font-weight:bold; }
.normal { font-weight:normal; color: #AAAAAA; background-color: #000000; }
.reverse { background-color: #2A2A2A; }
.underline { text-decoration: underline; }
.line-through { text-decoration: line-through; }
.blink { text-decoration: blink; }
</style>
<title>xterm ansi color screenshot -> html</title>
</head>
<html>
<body bgcolor=\"#000000\" text=\"#ffffff\">
<pre>
"
#<meta content="charset=UTF-8">
#<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
#<meta http-equiv="content-type" content="text/html; charset=UTF-8">
p='↗[^↖]*\<'
e='\>[^↖]*'
echo '<span>'
sed 's/\xef\xbf\xbf//g'|\
sed 's#\&#\&#g; s#>#\>#g; s#<#\<#g'|\
#sed 's#\"#\"#g; s#\ +#\&nbsp;#g'|\
sed 's#\x1b\#[0-9]##g'|\
#sed 's#\x1b\[0m##g'|\
sed 's#\x1b\[\([0-9;]*\)m#↗\1↖#g'|\
sed "s#${p}1${e}#& bold#g"|\
sed "s#${p}4${e}#& underline#g"|\
sed "s#${p}5${e}#& blink#g"|\
sed "s#${p}7${e}#& reverse#g"|\
sed "s#${p}9${e}#& line-through#g"|\
sed "s#${p}3\([0-7]\)${e}#& f\1#g"|\
sed "s#${p}4\([0-7]\)${e}#& b\1#g"|\
#sed "s#↗0↖##g"|\
sed "s#↗[0-9;\ ]\+#</span><span class=\"#g"|\
sed "s#↖#\">#g"|\
#sed "s#^#</span><span class=\"normal\">#g"|\
tr -d "\r"|\
cat
echo '</span>'

echo "</pre>
</body>
</html>
"
来研究这个吧
好像是火星文字!

Re: sed 's/.*\(.\)$/\1/' 与 sed 's/.*\///g'都是什么意思

发表于 : 2009-11-17 14:34
xjpvictor
ee那是神族语言

Re: sed 's/.*\(.\)$/\1/' 与 sed 's/.*\///g'都是什么意思

发表于 : 2009-11-17 22:50
lnitcscq
eexpress 写了:

代码: 全选

● cat ansi2html.bash 
#!/bin/bash

# Convert ANSI (terminal) colour codes to HTML
# Last Modify: eexpress @ 2009-02-27
# Author:
#    http://www.pixelbeat.org/docs/terminal_colours/

echo -n "
<head>
<style type=\"text/css\">
/* linux console palette */
.f0 { color: #000000; }
.f1 { color: #FF0000; }
.f2 { color: #00AA00; }
.f3 { color: #E5E414; }
.f4 { color: #5B5BFC; }
.f5 { color: #FF00FF; }
.f6 { color: #01FEFD; }
.f7 { color: #AAAAAA; }
.bf0 { color: #555555; }
.bf1 { color: #FF5555; }
.bf2 { color: #55FF55; }
.bf3 { color: #FFFF55; }
.bf4 { color: #5555FF; }
.bf5 { color: #FF55FF; }
.bf6 { color: #55FFFF; }
.bf7 { color: #FFFFFF; }
.b0 { background-color: #000000; }
.b1 { background-color: #AA0000; }
.b2 { background-color: #00AA00; }
.b3 { background-color: #CDCD00; }
.b4 { background-color: #0000AA; }
.b5 { background-color: #AA00AA; }
.b6 { background-color: #00AAAA; }
.b7 { background-color: #E5E5E5; }
.bold { font-weight:bold; }
.normal { font-weight:normal; color: #AAAAAA; background-color: #000000; }
.reverse { background-color: #2A2A2A; }
.underline { text-decoration: underline; }
.line-through { text-decoration: line-through; }
.blink { text-decoration: blink; }
</style>
<title>xterm ansi color screenshot -> html</title>
</head>
<html>
<body bgcolor=\"#000000\" text=\"#ffffff\">
<pre>
"
#<meta content="charset=UTF-8">
#<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
#<meta http-equiv="content-type" content="text/html; charset=UTF-8">
p='↗[^↖]*\<'
e='\>[^↖]*'
echo '<span>'
sed 's/\xef\xbf\xbf//g'|\
sed 's#\&#\&#g; s#>#\>#g; s#<#\<#g'|\
#sed 's#\"#\"#g; s#\ +#\&nbsp;#g'|\
sed 's#\x1b\#[0-9]##g'|\
#sed 's#\x1b\[0m##g'|\
sed 's#\x1b\[\([0-9;]*\)m#↗\1↖#g'|\
sed "s#${p}1${e}#& bold#g"|\
sed "s#${p}4${e}#& underline#g"|\
sed "s#${p}5${e}#& blink#g"|\
sed "s#${p}7${e}#& reverse#g"|\
sed "s#${p}9${e}#& line-through#g"|\
sed "s#${p}3\([0-7]\)${e}#& f\1#g"|\
sed "s#${p}4\([0-7]\)${e}#& b\1#g"|\
#sed "s#↗0↖##g"|\
sed "s#↗[0-9;\ ]\+#</span><span class=\"#g"|\
sed "s#↖#\">#g"|\
#sed "s#^#</span><span class=\"normal\">#g"|\
tr -d "\r"|\
cat
echo '</span>'

echo "</pre>
</body>
</html>
"
来研究这个吧
看不懂,能不能加些注释啊。

Re: sed 's/.*\(.\)$/\1/' 与 sed 's/.*\///g'都是什么意思

发表于 : 2009-11-17 23:07
Jarson
斗胆分析一下
第一个:只保留一行中的最后一个字符(也许只是一个空格)。
第二个:删除一行中所有以 / 结尾的字符(包括数字等,这里用字符来指代)串。

Re: sed 's/.*\(.\)$/\1/' 与 sed 's/.*\///g'都是什么意思

发表于 : 2009-11-18 0:09
beruchtigte
转义