Magazine

Understanding on

Posted on the 03 April 2021 by Satish Kumar @satish_kumar86

Theherestring is used forinputredirection from <indexentry content=”<<text or a variable. Input is mentioned on the same line within single quotes ('').

The syntax is as follows:

$ command <<< 'string'
  • Let’s see the following example,hereString_01.sh:
hereString_01.sh
#!/bin/bash 
wc -w <<< 'Good Morning and have a nice day !' 
  • Save the file, give the permission, and run the script as follows:
$ chmod u+x hereString_01.sh
$ ./hereString_01.sh
  • Here is the output:
Output:
8

In this example, the string Good Morning and have a nice day ! is called as the here string.


You Might Also Like :

Back to Featured Articles on Logo Paperblog

These articles might interest you :