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 ...

Get Learning Linux Shell Scripting - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.