Skip to content
Advertisement

Is every command handled differently in input redirection in a shell (linux)?

For example wc -l filename would print out for example “3 filename”,
while wc -l < filename would print out only “3” disregarding “filename”.
This means there must have been some program that got rid of “filename” with the addition of input redirection “<“. Also that means input redirection handles every command differently; such as “cat filename” would print out the entire filename to the output, and etc.

Advertisement

Answer

Is every command handled differently in input redirection in a shell (linux)?

No, the shell handles redirections identically. It’s the individual program that decides how it handles its input.

wc and cat both can handle files passed as arguments. If they are not passed any arguments, they process input from stdin.

However, what they do with the file names vs stdin is entirely up to them.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement