Sending data to an embedded language code

If we want to send data to the embedded language script, then one way is to send it via variable content. Look at the following example:

    $ export location="/etc"; ksh -c "ls $location"
  

In the preceding example, we are initializing a variable location with the path or folder name. When shell executes the  ksh command, it will pass path as content of $location. Then, ksh will print the content of the directory required.

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.