This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / Sailor和Egg,看你们“啊”得这么起劲,来回答我的问题:为什么echo \\和echo \\\\的结果都是\,echo \\\\\\和echo \\\\\\\\的结果都是\\,而echo \\\\\\\\\\和echo \\\\\\\\\\\\的结果都是\\\呢?
-pasu(InTheSky);
2001-4-26
(#54451@0)
-
Is it from Unix/Linux? Don't tell me it is from Dos/Windows.
-guest:;
2001-4-26
(#54456@0)
-
Bourne Shell
-pasu(InTheSky);
2001-4-26
(#54458@0)
-
numnum? any body?
-pasu(InTheSky);
2001-4-26
(#54469@0)
-
后边的那些都被忽略了
-shou(小受);
2001-4-26
(#54473@0)
-
Detail! From which?
-pasu(InTheSky);
2001-4-26
(#54477@0)
-
只有idiot才研究这种问题。in shell, \\ = \? sorry, I'm a idiot on UNIX.
-eglington(eglington);
2001-4-26
(#54476@0)
-
Explain again: echo 2 \ and 4 \ get 1 \; echo 6 \ and 8 \ get 2 \; echo 10 \ and 12 \ get 3 \. Why?
-pasu(InTheSky);
2001-4-26
(#54483@0)
-
The backslash is intepreted by shell. \\=\. I got 4 \ when I put 8 \ on tcsh. I am glad to talk about it further with you.
-chengyu(Chuan);
2001-4-26
(#54502@0)
-
Thx! I know \\ = \. But I was really puzzled by so many \'s lined up.
-pasu(InTheSky);
2001-4-26
(#54516@0)
-
don't know,,, you are a weird guy, always studying weird problems. hehe
-numnum(numnum);
2001-4-26
(#54489@0)
-
Help me. At least explain why echo \\ and echo \\\\ are both producing \?
-pasu(InTheSky);
2001-4-26
(#54512@0)
-
okay, I already know why, any prize?
-numnum(numnum);
2001-4-26
(#54517@0)
-
I will go to watch how do you put the ring on lumlum's finger. xixi.
-pasu(InTheSky);
2001-4-26
(#54522@0)
-
be patient, I am writing the answer, it's a bit complicated to explain all this
-numnum(numnum);
2001-4-26
(#54529@0)
-
NP&THX
-pasu(InTheSky);
2001-4-26
(#54531@0)
-
me too.
-lumlumq(lumlum);
2001-4-26
(#54533@0)
-
be patient. he's working for the answer. it's a bit complicated to work out the whole thing. hehe.
-pasu(InTheSky);
2001-4-26
(#54539@0)
-
不行啦,我肚子笑得要抽筋啦……
-bxy(西岭);
2001-4-26
(#54545@0)
-
Why do you laugh at a guy he is really serious about romance? Do not laugh, just be patient.
-guest:;
2001-4-26
(#54610@0)
-
?
-bxy(西岭);
2001-4-26
(#54670@0)
-
There are two layers of escape you need to consider: shell itself, and echo program
-numnum(numnum);
2001-4-26
{1382}
(#54551@0)
-
THX! The key to me is :"Echo has a peculiar behavior that when it encounters a single "\" who doesn't have anybody else to escape, it will print out "\" anyway. " I know the rest. And I did not ask this question for fun.Cuz I wrote below statement in my script:
sed s/\\\\//\\\\\\\\\\\\//g tmpfile
And I was really puzzled when I tune this script. I had to try many times to get the correct form.
hehe...What's more, do you know what did I want to do with the statement above?
-pasu(InTheSky);
2001-4-26
{282}
(#54557@0)
-
嘿嘿,你整天就搞些怪东西, 你用nawk应该会好多了
-lumlumq(lumlum);
2001-4-26
(#54571@0)
-
awk要调解释器,麻烦,而且运行级别低的时候不能用。而且个人认为awk的长处是做运算和有比较复杂流程的任务,比方说处理log之类的;文本处理还是用ed、sed和tr比较爽。虽然regexp比较晦涩,但是其实很好用;喜欢摆弄它就象有的人喜欢开手动档的汽车一样。不过可惜还没玩熟,而且还老容易忘。
-pasu(InTheSky);
2001-4-26
{34}
(#54591@0)
-
exactly.
-guest:;
2001-4-26
(#54606@0)
-
awk is almost as simple as sed, you can put the script directly in the command line. It has a much more complete set of utilities, sometimes it is viewed as a programming language, like perl.Actully, I only use sed as "sed -n "s/***/88/g" " because it already beomes a habit.
-numnum(numnum);
2001-4-27
{88}
(#55208@0)
-
Yes, awk is a script language indeed. It's the very reason I don't want to use it to deal with the text. You know, you will have to almost re-write a part of sed, ed or tr. Why not use a provided utillity?
-pasu(InTheSky);
2001-4-27
(#55359@0)
-
BTW, How did you know the stupid feature of echo? I cannot get it from man page. Is there any document for it?
-pasu(InTheSky);
2001-4-27
(#54632@0)
-
感觉啦,如果只有一个”\”,他ESCAPE谁去啊?但你不能就这么忽视它巴,这些东西很多都是COMMON的。 后来写程序时候,
用execlp()把ECHO绕过SHELL调用了一下,证明是这样。 好了,要上班去啦。。。呵呵,等会再聊
-numnum(numnum);
2001-4-27
(#55154@0)
-
我还以为你看过source code呢,呵呵。Thx!
-pasu(InTheSky);
2001-4-27
(#55168@0)
-
heihei, I'm in the office now, just got a cup of coffee. Echo's source code should be really simple, I have written some kind of regular expression library for real time system, it's common sense how to interpret certain things.
-numnum(numnum);
2001-4-27
(#55195@0)
-
Obviously it's common to you programmers. hehe...
-pasu(InTheSky);
2001-4-27
(#55348@0)