Bash Input re-direction gives standard input into the command instead of parameter / filename?
Simply try this:
ls $(<com)
/bin/ls
, like many other standard un*x commands, work with command line arguments, not with STDIN.
You could write:
ls $(cat com)
bash do permit syntax: $(< filename) and work quicker than $(cat ...) or cat com
because work as builtin (no fork).
Using STDIN for passing arguments
There is a command xargs
for doing this:
xargs /bin/ls <com
But this won't work with wildcard (*
).
echo $(<com) | xargs ls
As far as I understand, the shell will take the input Chapter* from the file "com" and place it next to ls
No, that's not what it means.
ls < com
is equivalent to
cat com | ls
Since ls
doesn't read it's standard input, the data from com
is ignored. The behavior you're describing is achieved, as another answer mentioned, by using:
ls $(<com)