← Back to Bash Course | Chapter 2: Variables & Types | Lesson 9 of 13

export कमांड

export अपना note की एक copy उन friends को देने जैसा है जिन्हें आप बुलाते हैं। इसके बिना, note आपकी pocket में रहता है और जो programs आप start करते हैं वे इसे नहीं देख सकते।

In this page:

  1. export
Syntax
bash
export VARIABLE_NAME="value"

export

export एक variable को mark करता है ताकि यह script द्वारा start किए गए किसी भी child processes में pass हो जाए, जैसे दूसरे scripts या programs जिन्हें यह call करता है। export के बिना, एक variable सिर्फ current shell के अंदर मौजूद होता है और subprocesses के लिए invisible होता है।

यह वह तरीका है जिससे scripts अपने द्वारा invoke किए गए programs के साथ configuration share करते हैं।

Note: जब एक variable को आपके script द्वारा call किए गए program को visible होना चाहिए, सिर्फ script को नहीं, तो export VAR=value उपयोग करें।

उदाहरण: export

bash
#!/bin/bash
export GREETING="Hello from parent"

bash -c 'echo "Child sees: $GREETING"'
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. यह उम्मीद करना कि एक exported variable parent shell बदल देगा, जब export सिर्फ values को child processes में pass करता है।
  2. एक variable export करना और फिर इसे एक child में बदलना, जो parent की value नहीं बदलता।
  3. एक variable export करना भूल जाना जिसकी called script को ज़रूरत है, इसलिए वह वहां empty रहता है।

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.