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

Sending output to Bash Script

There are many ways to send or receive data from embedded code. Other language-embedded code can send data to Bash using piping, saving, writing, or printing. Other language-embedded code can receive data through variables, files, user input, or pipes.

The following is an example of other language code sending output to Bash using pipe:

    ksh -c "ls" | cat > ./save_to_file
  

In the preceding command, ksh is sending directory content to bash by pipe, which will be stored in the file.

We can eliminate the use of pipe from the preceding example as follows:

    ksh -c "ls" > ./save_to_file
  

As we have eliminated the use of pipe, the preceding command has become more efficient. It is better to eliminate the middleman if ...

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