Cshell commands
When I receive lines one by one, why do programmers sometimes write:
set line = ($<)
set开发者_如何学C line = ($line)
What exactly do those rows mean?
I found a csh overview here: http://linux.die.net/man/1/csh
I appreciate you may not use Linux but I always found O'Reilly's Linux in a Nutshell book great for shell scripting.
To specifically address your questions (from the post above so I could be wrong!)
- $< : get next line from stdin
- ($line) : will execute the contents of $line in a subshell
Of course, like all things with Csh - you should probably just use Bash and live happier :)
Dan
set line = ($<)
This reads a line of input from stdin and then splits it into an array, separating words by white-space, so that $line[1]
is the first word, $line[2]
is the second word and so on.
set line = ($line)
This does the same as above, but where $line might have been a single word, it will become an array of words. i.e.:
set line = ($<)
is the same as:
set line = "$<"
set line = ($line)
精彩评论