Triple input redirection symbol in bash script

43 Views Asked by At

I saw a code like this that could be run on the bash prompt: bc fibonacci.bc <<< "fibonacci(1)" A function fibonacci(n)is defined in the file fibonacci.bc. The syntax of the function follows bc syntax rules. The redirection symbol <<< looks new to me. Can somebody throw some light on it?

1

There are 1 best solutions below

4
jeremy-denis On

The <<< symbol is used to pass a string as the standard input of the command used.

It's called a here-string.

The simplest example is with cat:

cat <<< 'hello'

You can find a first explanation in the man bash page https://www.gnu.org/software/bash/manual/html_node/Redirections.html#Here-Strings