Skip to Content
Learning Linux Shell Scripting - Second Edition
book

Learning Linux Shell Scripting - Second Edition

by Ganesh Sanjiv Naik
May 2018
Beginner
332 pages
7h 28m
English
Packt Publishing
Content preview from Learning Linux Shell Scripting - Second Edition

The here string and the <<< operator

The here string is used for input redirection from <indexentry content="<<text or a variable. Input is mentioned on the same line within single quotes ('').

The syntax is as follows:

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

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

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Linux Shell Scripting

Learning Linux Shell Scripting

Ganesh Sanjiv Naik
Linux Shell Scripting Cookbook - Third Edition

Linux Shell Scripting Cookbook - Third Edition

Clif Flynt, Sarath Lakshman, Shantanu Tushar

Publisher Resources

ISBN: 9781788993197Supplemental Content