How to use a bash variable, which holds a value to the below subsequent cells in Data bricks notebook?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 12:54 PM
%sh
export a
a=100
echo $a
OUTPUT: 100
in the below cell trying to use the variable a, but it's not printing the value
%sh
echo $a
OUTPUT:
- Labels:
-
Azure databricks
-
Global
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 12:59 PM
Hi, bash is not supported as notebook language. Instead, it is a magic cell executing shell script on the driver node.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 01:22 PM
Okay...
In data bricks notebook, is there a way to declare a bash variable as a global variable and use that variable's value in the subsequent cells in the notebook?
like mentioned in the attachment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 02:01 PM
You can configure custom environment variables
- On the cluster configuration page, click the Advanced Options toggle.
- Click the Spark tab.
- Set the environment variables in the Environment Variables field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2022 05:12 PM
Hi Kaniz, seems this is limitation in databricks notebook(S)
"How to use a bash variable, which holds a value to the below subsequent cells in Data bricks notebook?"
So alternatively, i used all commands in the same cell and moved forward, i didn't find any alternative as of now

