why is ls -l
not equivalent to ls < some_params.txt
where some_params.txt
would contain -l
?
Because the command line isn't the standard input!
ls
is not a very good example here, since it doesn't use standard input. It just processes the command line options it gets, looks through some directories, and prints a listing to standard output.
But consider something like cat -n
. It takes the -n
flag from the command line, then reads from its standard input, adds line numbers and prints to standard output. Without < filename
, the input comes from the terminal (i.e. your keyboard). With it, it comes from a file.
What you could do is use command substitution to insert the contents of a file to the command line. ls $(cat some_params.txt)
(or ls $(< some_params.txt)
in shells that support it) would do what you propose.