简体   繁体   English

这如何计算文件中的行数? no_of_lines=`<$file wc -l`

[英]How does this work to count number of lines in a file? no_of_lines=`<$file wc -l`

I can almost undestand why我几乎可以理解为什么

no_of_lines=`wc -l <$file`

stores the number of lines in file.存储文件中的行数。 But how does但是怎么做

no_of_lines2=`<$file wc -l`

also give the same answer?也给出相同的答案?

Shell trivia: Redirections don't have to come after commands. Shell 琐事:重定向不必在命令之后。 That's where people usually put them, but they can actually be anywhere—at the end, at the beginning, or even in the middle.这是人们通常将它们放置的位置,但它们实际上可以放在任何地方——在结尾、开头,甚至在中间。

These are all equivalent:这些都是等价的:

wc -l <file
<file wc -l
wc <file -l

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM