cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to use a bash variable, which holds a value to the below subsequent cells in Data bricks notebook?

VeeraNerella
New Contributor III

%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:

4 REPLIES 4

Hubert-Dudek
Esteemed Contributor III

Hi, bash is not supported as notebook language. Instead, it is a magic cell executing shell script on the driver node.

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

Hubert-Dudek
Esteemed Contributor III

You can configure custom environment variables

  1. On the cluster configuration page, click the Advanced Options toggle.
  2. Click the Spark tab.
  3. Set the environment variables in the Environment Variables field.

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

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!

Sign Up Now