In most cases the result will be the same. The difference is:
- with
cat test
you tell thecat
program to open the file itself - with
cat < test
you tell the shell to open the file and feed it tocat
You could notice a difference in behavior for example when running a program with superuser priviledges. If your regular user can't access test
file but superuser can, than:
sudo cat test
will be able to print the filesudo cat < test
will not
This is because sudo
causes cat
to be run as superuser, but doesn't affect the shell's priviledges, so depending on whether cat
or the shell is opening the file, this operation will succeed or fail.