Question

What does the < symbol mean and when should I use it?

I understand > and >>.

Also, are there any other symbols like this?

Was it helpful?

Solution

In most cases the result will be the same. The difference is:

  • with cat test you tell the cat program to open the file itself
  • with cat < test you tell the shell to open the file and feed it to cat

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 file
  • sudo 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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top