-1

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?

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
  • Please take a look at [benefit-of-using-instead-of-backticks-in-shell-scripts](https://stackoverflow.com/questions/9449778/what-is-the-benefit-of-using-instead-of-backticks-in-shell-scripts) – Francesco Jun 10 '20 at 16:09

1 Answers1

1

Shell trivia: Redirections don't have to come after commands. 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
John Kugelman
  • 349,597
  • 67
  • 533
  • 578