What are the operators <<
and <
used for in Linux?
For example
cat << abc.txt
What are the operators <<
and <
used for in Linux?
For example
cat << abc.txt
<
is used to redirect input. Saying
command < file
executes command
with file
as input.
The <<
syntax is referred to as a here document. The string following <<
is a delimiter indicating the start and end of the here document.
$ cat abc.txt
cat: abc.txt: No such file or directory
$ cat << abc.txt
> Hello!
> Hey :)
> abc.txt
Hello!
Hey :)
$
<<
doesn't indicate any sort of indirection.
You might also want to refer to redirection and here document.
<<
will act as input if i say grep "somestring" << filename.txt
...just asking to clear out my head on this!!
– NoobEditor
Feb 10 '14 at 08:58
filename.txt
would be treated as a delimiter. Nothing would be read from the file.
– devnull
Feb 10 '14 at 09:00