is ____it is easy to? i do n...

& 2013 - 2014 作业宝. All Rights Reserved. 沪ICP备号-9当前位置:
>>>This machine is very easy ________. Anybody can learn to us..
This machine is very easy ________. Anybody can learn to use it in a few minutes.
A. operating&&B. to be operating C. operated&&D. to operate
题型:单选题难度:中档来源:专项题
马上分享给同学
据魔方格专家权威分析,试题“This machine is very easy ________. Anybody can learn to us..”主要考查你对&&不定式&&等考点的理解。关于这些考点的“档案”如下:
现在没空?点击收藏,以后再看。
因为篇幅有限,只列出部分考点,详细请访问。
动词不定式的概念:
动词不定式指由to加上动词原形(而且只能是动词原形)所构成的一种非限定性动词,但在有些情况下to可以省略。动词不定式在语法功能上可作主语、宾语、宾语补足语、表语、定语和状语。不定式的特殊句型对比:
1、不定式的特殊句型too…to…: 1)too…to 太…以至于…。例如:He is too excited to speak. 他太激动了,说不出话来。 &&&&&&&&&—Can I help you? 需要我帮忙吗? &&&&&&& —Well, I'm afraid the box is too heavy for you to carryi t, but thank you all the same. 不用了。这箱子太重,恐怕你搬不动。谢谢。 2)如在too前有否定词,则整个句子用否定词表达肯定,too后那个词表达一种委婉含义,意为“不太”。例如:It's never too late to mend. 改过不嫌晚。(谚语) 3)当too前面有only, all, but时,意思是:非常…等于very。例如:I'm only too pleased to be able to help you. 能帮助你我非常高兴。  &&&&&&&&&&& He was but too eager to get home. 他非常想回家。 2、不定式的特殊句型so as to:1)表示目的:它的否定式是so as not to do。例如:Tom kept quiet about the accident so as not to lose his job. 汤姆对事故保持沉默是为了不丢掉他的工作。   &&&&&&&&&&& Go in quietly so as not to wake the baby. 轻点进去,别惊醒了婴儿。 2)表示结果:例如:Would you be so kind as to tell me the time? 劳驾,现在几点了。 3、不定式的特殊句型:Why not: “Whynot+动词原形”表达向某人提出建议,翻译为:为什么不……?&& 干吗不……?例如:Why not take a holiday?不定式的用法:
1、不定式作补语:1)有些有动词+宾语+不定式的结构。例如:advise allow cause challenge command compel drive驱使 enable encourage forbid force impel induce instruct invite like/love order permit make let have want get warn persuade request send tell train urge 等。例如:Father will not allow us to play on the street. 父亲不让我们在街上玩耍。       &&&&&&&&&&& The officer ordered his men to fire. 长官命令士兵开火。注意:有些动词如make,have,get,want等可用不定式作做宾补,也可用分词作宾补。现在分词表达主动,也表达正在进行,过去分词表达被动。 2)有些有动词+宾语+不定式的结构,不定式的动词往往是be,不定式一般可以省去。例如:consider find believe think declare(声称) appoint guess fancy(设想) guess judge imagine know 等。 例如:We believe him to be guilty. 我们相信他是有罪的。&&&&&&&&&&&&&We know him to be a fool. 我们知道他是个笨蛋。(tobe不能省去)典型例题:Charles Babbage is generally considered___the first computer. &&&&&&&&&&&&&&&&&&& A. to invent &&&&&&&&&&&&&&&&&&& B. inventing &&&&&&&&&&&&&&&&&&& C. to have invented &&&&&&&&&&&&&&&&&&& D. having invented 答案:C. 一般没有consider+宾语+be以外不定式的结构,也没有consider+宾语+doing的结构,排除A、B、D。consider用动词be以外的不定式作宾补时,一般要求用不定式的完成式,故选C。 3)有些动词可以跟there+to be的结构。例如:believe expect intend like love mean prefer want wish understand 等。例如:We didn't expect there to be so many people there. 我们没料到会有那么多人在那里。 &&&&&&&&&&& You wouldn't want there to be another war. 你不至于想让另外一场战争发生吧。 2、不定式作主语:不定式作主语,往往用it作形式主语,真正的主语不定式放至句子的后面。 例如:It's so nice to hear your voice. 听到你的声音真高兴。 &&&&&&&&&&& It's necessary for you to lock the car when you do not use it. 不用车的时候,锁车是有必要的。  &&&&&&&&&&& It's very kind of you to help us. 他帮助我们,他真好。  &&&&&&&&&&& It seemed selfish of him not to give them anything. 他不给他们任何东西,这显得太自私了。3、不定式作表语:不定式可放在be动词后面,形成表语。例如:My work is to clean the room every day. 我的工作是每天清扫房间。  &&&&&&&&&&& His dream is to be a doctor. 他的梦想是成为一名医生。 4、不定式作定语:不定式做定语通常要放在被修饰的词后,往往表示未发生的动作。例如:I have a lot of work to do.我有许多事要做。   &&&&&&&&&&& There was nothing to bring home that morning. 那天早上(他回家时)两手空空。 5、不定式作状语:1)目的状语:常用结构为to do,only to do(仅仅为了), in order to do,so as to do,so(such)...asto…(如此…以便…)。例如:He ran so&fast as to catch the first bus. 他飞快地跑以便赶上第一班车。   &&&&&&&&&&& I come here only to say good-bye to you. 我来仅仅是向你告别。 2)作结果状语,可以表示没有预料到的或事与愿违的结果,不定式要放在句子后面。 例如:I awoke to find my truck gone. 我醒来发现箱子不见了。   &&&&&&&&&&& He searched the room only to find nothing. 他搜索了房间,没发现什么。 3)表原因:例如:I'm glad to see you.& 见到你很高兴。 &&&&&&&&&&& She wept to see the sight. 她一看到这情形就哭了。 4)表示理由和条件: 例如:He must be a fool to say so. &&&&&&&&&&& You will do well to speak more carefully.&&&&&&&&&&& You will do well to speak more carefully. 不定式知识体系:
&不定式用法拓展:
1、用作介词的to:to可以用作介词,也可用作不定式的标示。下面的to都用作介词:admit to& object to& beaccus to& med to& beused to& stick to& turn to开始 look forward to& be devoted to& pay attention to &contribute to apologize to devote oneself to 2、省去to的动词不定式: 1)情态动词(除ought外)后。 2)使役动词let,have,make后,感官动词see, watch, lookat, notice, observe, hear, listento, smell, feel, find等后。注意:被动语态中不能省去to。例如:I saw him dance. 我看见他跳舞。=He was seen to dance.   &&&&&&&&&& The boss made them work the whole night. 老板让他们整夜干活。 =They were made to work the whole night. 3)would rather,had better句型后: 4)Why…/why not…句型后:5)help后可带to,也可不带to, help sb(to)do sth: 6)but和except后:but前是实义动词do时,后面出现的不定式不带to。比较:He wants to do nothing but go out. 他只想出去玩。   &&&&&&&&&&& He wants to believe anything but to take the medicine. 除了吃这药,他什么都信。 7)由and, or和than连接的两个不定式,第二个to可以省去: 8)通常在discover, imagine, suppose, think等词后作宾补时,可以省去to be。例如:He is supposed(to be)nice. 他应该是个好人。 3、动词不定式的否定式在不定式标志to前加上not。例如:Tell him not to shut the window。让他别关窗。  &&&&&&&&&&& She pretended not to see me when I passed by. 我走过的时候,她假装没看见。4、It's for sb. 和It's of sb. 这样的句子中,由于表语形容词性质的不同,导致了不定式逻辑主语标志用for或of的区别。 1)for sb. 句型中的形容词一般为表示事物的特征特点,表示客观形式的形容词,如easy, hard, difficult, interesting, impossible等:例如:It's very hard for him to study two languages. 对他来说学两门外语是很难的。 2)of sb句型中的形容词一般为表示性格,品德,心智能力,表示主观感情或态度的形容词,如good, kind, nice, clever, foolish, right。例如:It's very nice of you to help me. 你来帮助我,你真是太好了。用for还是用of的另一种辨别方法:用介词for或of后面的逻辑主语作句子的主语,用介词前边的形容词作表语,造个句子。如果通顺用of,不通则用for。例如:You are nice.(通顺,所以应用of)。  &&&&&&&&&&&&He is hard.(非所表达的意思,不通,因此用for。)
发现相似题
与“This machine is very easy ________. Anybody can learn to us..”考查相似的试题有:
209080212707229400178080215123203296Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
I unsuccesfully tried:
sed 's#\n# #g' file
sed 's#^$# #g' file
How to fix it?
20.7k53674
7,7121970134
Or use this solution with sed:
sed ':a;N;$!s/\n/ /g'
This will read the whole file in a loop, then replaces the newline(s) with a space.
Update: explanation.
create a label via :a
append the current and next line to the pattern space via N
if we are before the last line, branch to the created label $!ba ($! means not to do it on the last line (as there should be one final newline)).
finally the substitution replaces every newline with a space on the pattern space (which is the whole file).
22.2k64365
Use tr instead?
tr '\n' ' ' & input_filename
14.5k75590
53.3k1389161
Fast answer:
sed ':a;N;$!s/\n/ /g' file
:a create a label 'a'
N append the next line to the pattern space
$! if not the last line, ba branch (go to) label 'a'
s substitute, /\n/ regex for new line, / / by a space, /g global match (as many times as it can)
sed will loop through step 1 to 3 until it reach the last line, getting all lines fit in the pattern space where sed will substitute all \n characters
Alternatives:
All alternatives, unlike sed will not need to reach the last line to begin the process
with bash, slow
do printf "%s" "$line "; done & file
with perl, sed-like speed
perl -p -e 's/\n/ /' file
with tr, faster than sed, can replace by one character only
tr '\n' ' ' & file
with paste, tr-like speed, can replace by one character only
paste -s -d ' ' file
with awk, tr-like speed
awk 1 ORS=' ' file
Other alternative like "echo $(& file)" is slow, works only on small files and needs to process the whole file to begin the process.
Long answer from the :
5.10. Why can't I match or delete a newline using the \n escape
sequence? Why can't I match 2 or more lines using \n?
The \n will never match the newline at the end-of-line because the
newline is always stripped off before the line is placed into the
pattern space. To get 2 or more lines into the pattern space, use
the 'N' command or something similar (such as 'H;...;g;').
Sed works like this: sed reads one line at a time, chops off the
terminating newline, puts what is left into the pattern space where
the sed script can address or change it, and when the pattern space
is printed, appends a newline to stdout (or to a file). If the
pattern space is entirely or partially deleted with 'd' or 'D', the
newline is not added in such cases. Thus, scripts like
sed 's/\n//' file
# to delete newlines from each line
sed 's/\n/foo\n/' file
# to add a word to the end of each line
will NEVER work, because the trailing newline is removed before
the line is put into the pattern space. To perform the above tasks,
use one of these scripts instead:
tr -d '\n' & file
# use tr to delete newlines
sed ':a;N;$!s/\n//g' file
# GNU sed to delete newlines
sed 's/$/ foo/' file
# add "foo" to end of each line
Since versions of sed other than GNU sed have limits to the size of
the pattern buffer, the Unix 'tr' utility is to be preferred here.
If the last line of the file contains a newline, GNU sed will add
that newline to the output but delete all others, whereas tr will
delete all newlines.
To match a block of two or more lines, there are 3 basic choices:
(1) use the 'N' command to add the Next line
(2) use the 'H' command at least twice to append the current line
to the Hold space, and then retrieve the lines from the hold space
with x, g, or G; or (3) use address ranges (see section 3.3, above)
to match lines between two specified addresses.
Choices (1) and (2) will put an \n into the pattern space, where it
can be addressed as desired ('s/ABC\nXYZ/alphabet/g'). One example
of using 'N' to delete a block of lines appears in section 4.13
("How do I delete a block of specific consecutive lines?"). This
example can be modified by changing the delete command to something
else, like 'p' (print), 'i' (insert), 'c' (change), 'a' (append),
or 's' (substitute).
Choice (3) will not put an \n into the pattern space, but it does
match a block of consecutive lines, so it may be that you don't
even need the \n to find what you're looking for. Since GNU sed
version 3.02.80 now supports this syntax:
sed '/start/,+4d'
# to delete "start" plus the next 4 lines,
in addition to the traditional '/from here/,/to there/{...}' range
addresses, it may be possible to avoid the use of \n entirely.
3,82131825
A shorter awk alternative:
awk 1 ORS=' '
Explanation
An awk program is built up of rules which consist of conditional code-blocks. If the code block is omitted the default ({ print $0 }) is used. Thus the 1 is interpreted as a true condition and print $0 is executed for each line.
When awk reads the input it splits it into records based on the value of RS (Record Separator), which by default is a newline, thus awk will by default parse the input linewise. The splitting also involves stripping off RS from the input record.
Now, when printing a record, ORS (Output Record Separator) is appended to it (default is again a newline). So by changing ORS to a space all newlines are changed to spaces.
14.3k42347
The perl version works the way you expected.
perl -i -p -e 's/\n//' file
Edit: As pointed out in the comments, it's worth noting that this edits in place. -i.bak will give you a backup of the original file before the replacement in case your regex isn't as smart as you thought.
35.2k1674102
Who needs sed? Here is the bash way:
cat test.txt | do echo -n "$line "; done
2,13961125
In order to replace all newlines with spaces using awk, without reading the whole file into memory:
awk '{printf "%s ", $0}' inputfile
If you want a final newline:
awk '{printf "%s ", $0} END {printf "\n"}' inputfile
You can use a character other than space:
awk '{printf "%s|", $0} END {printf "\n"}' inputfile
115k26163242
tr '\n' ' '
is the command.
Simple and easy to use.
56.3k176499
olldddd thread, but three things.
0.) tr (or cat, etc.) is absolutely not needed. (gnu) sed and (gnu) awk, when combined, can do 99.9% of any text processing you need.
1.) stream != line based. ed is a line-based editor. sed is not. See
for more information on the difference. Most people confuse sed to be line-based because it is, by default, not very greedy in its pattern matching for SIMPLE matches- for instance, when doing pattern searching and replacing by one or two characters, it by default only replaces on the first match it finds (unless specified otherwise by the global command). there would not even be a global command if it were line-based rather than STREAM-based, because it would evaluate only lines at a time. try running ed, you'll notice the difference. ed is pretty useful if you want to iterate over specific lines (such as in a for-loop), but most of the times you'll just want sed.
2.) That being said,
sed -e '{:q;N;s/\n/ /g;t q}' file
works just fine in GNU sed version 4.2.1. The above command will replace all newlines with spaces. It's ugly and a bit cumbersome to type in, but it works just fine. The {}'s can be left out, as they're only included for sanity reasons.
14.3k42347
I'm not an expert, but I guess in sed you'd first need to append the next line into the pattern space, bij using "N". From the section "Multiline Pattern Space" in "Advanced sed Commands" of the book
(Dale Dougherty and Arnold R O'Reilly 1997; page 107 in ):
The multiline Next (N) command creates a multiline pattern space by reading a new line of input and appending it to the contents of the pattern space. The original contents of pattern space and the new input line are separated by a newline. The embedded newline character can be matched in patterns by the escape sequence "\n". In a multiline pattern space, the metacharacter "^" matches the very first character of the pattern space, and not the character(s) following any embedded newline(s). Similarly, "$" matches only the final newline in the pattern space, and not any embedded newline(s). After the Next command is executed, control is then passed to subsequent commands in the script.
From man sed:
Append the next line of input to the pattern space, using an embedded newline character to separate the appended material from the original contents.
Note that the current line number changes.
to search (multiple) badly formatted log files, in which the search string may be found on an "orphaned" next line.
7,89523144
The answer with the :a label ...
... does not work in freebsd 7.2 on the command line:
( echo bar ) | sed ':a;N;$!s/\n/ /g'
sed: 1: ":a;N;$!s/\n/ /g": unused label 'a;N;$!s/\n/ /g'
But does if you put the sed script in a file or use -e to "build" the sed script...
> ( echo bar) | sed -e :a -e N -e '$!ba' -e 's/\n/ /g'
& cat & x.sed && eof
& ( echo bar) | sed -f x.sed
Maybe the sed in OS X is similar.
In response to the "tr" solution above, on Windows (probably using the Gnuwin32 version of tr), the proposed solution:
tr '\n' ' ' & input
was not working for me, it'd either error or actually replace the \n w/ '' for some reason.
Using another feature of tr, the "delete" option -d did work though:
tr -d '\n' & input
or '\r\n' instead of '\n'
@OP, if you want to replace newlines in a file, you can just use dos2unix (or unix2dox)
dos2unix yourfile yourfile
94.1k17109172
Easy-to-understand Solution
I had this problem. The kicker was that I needed the solution to work on BSD (osx) and GNU (linux, cygwin) sed and tr.
$ echo 'foo
| tr '\n' '\000' \
| sed 's:\x00\x00.*:\n:g' \
| tr '\000' '\n'
(has trailing newline)
Works on Linux, OS X, and BSD - even without UTF8 support or with a crappy terminal.
Use tr to swap the newline with another character.
NULL (\000 or \x00) is nice because it doesn't need utf-8 support and it's not likely to be used
Use sed to match the NULL
Use tr to swap back extra newlines if you need them
22.4k63149
Using Awk:
awk "BEGIN { o=\"\" }
{ o=o \" \" \$0 }
In some situation maybe you can change the RS to some other string or char, this way \n is available for sub/gsub
cat file | gawk 'BEGIN {RS="dn" } {gsub("\n"," ") ;print $0 }'
The power of shell scripting is that if you do not know how to do it in one way you can do it in another way. And many times you have more things to take into account than make a complex solution on a simple problem.
Regarding the thing that gawk is slow... and reads the file into memory, I do not know this but to me gawk seems to work with one line at the time and is very very fast (not that fast as some of the others but the time to write and test also counts) .
I process MB and even GB of data and the only limit I found is line size.
37.6k1598152
I used a hybrid approach to get around the newline thing by using tr to replace newlines with tabs, then replacing tabs with whatever I want.
In this case "
" since I'm trying to generate html breaks.
echo -e "a\nb\nc\n" |tr '\n' '\t' | sed 's/\t/ &br& /g'`
22.4k80270459
Replace newlines with any string, and replace the last newline too
The pure tr solutions can only replace with a single character, and the pure sed solutions don't replace the last newline of the input. The following solution fixes these problems, and seems to be safe for binary data (even with a UTF-8 locale):
printf '1\n2\n3\n' |
sed 's/%/%p/g;s/@/%a/g' | tr '\n' @ | sed 's/@/&br&/g;s/%a/@/g;s/%p/%/g'
1&br&2&br&3&br&
You could use xargs & it will replace \n with a space by default.
However, it would have problems if your input has any case of an unterminated quote, e.g. if the quote signs on a given line don't match.
It is sed that introduces the new-lines after "normal" substitution. First, it trims the new-line char, then it processes according to your instructions, then it introduces a new-line.
Using sed you can replace "the end" of a line (not the new-line char) after being trimmed, with a string of your choice, but, sed will output different lines. For example, suppose you wanted to replace the "end of line" with "===" (more general than a replacing with a single space):
PROMPT~$ cat &&EOF |sed 's/$/===/g'
first line
second line
first line===
second line===
3rd line===
To replace the new-line char with the string, you can, inefficiently though, use tr , as pointed before, to replace the newline-chars with a "special char" and then use sed to replace that special char with the string you want.
For example:
PROMPT~$ cat &&EOF | tr '\n' $'\x01'|sed -e 's/\x01/===/g'
first line
second line
first line===second line===3rd line===PROMPT~$
On Mac OS X (using FreeBSD sed):
# replace each newline with a space
printf "a\nb\nc\nd\ne\nf" | sed -E -e :a -e '$!N; s/\n/ /g; ta'
printf "a\nb\nc\nd\ne\nf" | sed -E -e :a -e '$!N; s/\n/ /g' -e ta
A solution I particularly like is to append all the file in the hold space and replace all newlines at the end of file:
$ ( echo bar) | sed -n 'H;${x;s/\n//g;p;}'
However, someone said me the hold space can be finite in some sed implementations.
11.6k24381
Bullet-proof solution. Binary-data-safe and POSIX-compliant, but slow.
requires input according to the
definitions, so NULL-bytes and too long lines are not allowed and each line must end with a newline (including the last line). This makes it hard to use sed for processing arbitrary input data.
The following solution avoids sed and instead converts the input bytes to octal codes and then to bytes again, but intercepts octal code 012 (newline) and outputs the replacement string in place of it. As far as I can tell the solution is POSIX-compliant, so it should work on a wide variety of platforms.
od -A n -t o1 -v | tr ' \t' '\n\n' | grep . |
do [ "0$x" -eq 012 ] && printf '&br&\n' || printf "\\$x"; done
POSIX reference documentation:
Both read, [, and printf are built-ins in at least bash, but that is probably not guaranteed by POSIX, so on some platforms it could be that each input byte will start one or more new processes, which will slow things down. Even in bash this solution only reaches about 50 kB/s, so it's not suited for large files.
Tested on Ubuntu (bash, dash, and busybox), FreeBSD, and OpenBSD.
To remove empty lines:
sed -n "s/^$//;t;p;"
sed -n "H;$ {x;s/\n/ /g;p;}" file
Does not work for huge file (buffer limit) but very efficient if enough memory to hold the file.
You can use this method also
sed 'x;G;1!h;s/\n/ /g;$!d'
Explanation
- which is used to exchange the data from both space (pattern and hold).
- which is used to append the data from hold space to pattern space.
- which is used to copy the pattern space to hold space.
1!h - During first line won't copy pattern space to hold space due to \n is
available in pattern space.
$!d - Clear the pattern space every time before getting next line until the
last line.
When the first line get from the input, exchange is made, so 1 goes to hold space and \n comes to pattern space, then appending the hold space to pattern space, and then substitution is performed and deleted the pattern space.
During the second line exchange is made, 2 goes to hold space and 1 comes to pattern space, then G append the hold space into the pattern space, then h copy the pattern to it and substitution is made and deleted. This operation is continued until eof is reached then print exact result.
22.4k80270459
This is really simple .. I really gt irritated when i found the solution .. There was just one more back slash missing ..
This is it..
sed -i "s/\\\\\n//g" filename
You can use xargs
seq 10 | xargs
seq 10 | xargs echo -n
Here is sed without buffers (good for real time output).
Example: replacing \n with &br/& break in HTML
echo -e "1\n2\n3" | sed 's/.*$/&&br\/&/'
2,13961125
This is a lot simpler than most answers, also it is working:
echo `sed -e 's/$/\ |\ /g' file`
2,13961125
protected by H2CO3
Thank you for your interest in this question.
Because it has attracted low-quality answers, posting an answer now requires 10
on this site.
Would you like to answer one of these
Not the answer you're looking for?
Browse other questions tagged
Top questions and answers
Important announcements
Unanswered questions
By subscribing, you agree to the
Stack Overflow works best with JavaScript enabled}

我要回帖

更多关于 love is easy 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信