Skip to content

XceptN’s Tech Stuff

All About Tech

How to Distinguish Environment Variables from Different Shells in “bash”?

Posted on April 9, 2009 By XceptN No Comments on How to Distinguish Environment Variables from Different Shells in “bash”?

Every instance of the command line shell (thus every process) on Unix (and hence Linux) has a different set of environment variables. Actually different shell instances you may have the same variable, but set to different values.

If you are doing a system wide job and you are using shell scripting, you would like to know whether you are referring to the same or different local environment variables. The Bourne Again SHell (bash) provides a handy syntax for that. The command line below

$ echo ${MYVAR/%/.$$}

will print the value of environment variable MYVAR with a dot and the process ID (PID) appended at the end of the value. e.g.:

$ ps
  PID TTY          TIME CMD
24768 pts/10   00:00:00 bash
25172 pts/10   00:00:00 ps
$ MYVAR=”Sample Text”
$ echo $MYVAR
Sample Text
$ echo ${MYVAR/%/.$$}
Sample Text.24768
$

Hope that helps…

linux, sysadm

Post navigation

Previous Post: How to Set/Check the Arguments Used with “ntpd” Service
Next Post: Open Source Virtualization for Smaller Carbon Footprint

Related Posts

Generating Patches for Linux Sources development
Reading for Linux Kernel internals development
Converting video’s for Motorola ROKR E6 linux
D/Port Replicator Headphone Not Working desktop
Mercurial (hg) Fails with “abort: error: Name or service not known” via a Proxy linux
A Baby Named “Linux”!! kernel

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • Dipping Toes into Nix Package Manager | Installing Freeplane
  • Fujitsu Workplace Protect Face Recognition Best Practices on Q704
  • Fujitsu STYLISTIC Q704 Fingerprint Scanner Problems
  • Two Generations of Computing Equipment…
  • IBM Model M Keyboard Goes Blank

Recent Comments

  1. r0cky on Fujitsu LIFEBOOK UH572 Ultrabook Touch Pad Review: Linux
  2. XceptN on Fujitsu LIFEBOOK UH572 Ultrabook Touch Pad Review: Linux
  3. r0cky on Fujitsu LIFEBOOK UH572 Ultrabook Touch Pad Review: Linux
  4. Kaylee on Mounting an LVM Logical Volume in an Oracle VM Disk Image
  5. Theron Conrey on Open Source Virtualization for Smaller Carbon Footprint

Archives

  • June 2024
  • November 2014
  • October 2014
  • April 2014
  • March 2014
  • December 2012
  • November 2012
  • October 2010
  • April 2010
  • April 2009
  • March 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • October 2008
  • September 2008

Categories

  • blogging
  • communication
  • desktop
  • development
  • firmware
  • Fujitsu
  • gprs
  • gps
  • hardware
  • internet
  • java
  • kernel
  • keyboard
  • linux
  • masteryourbiz
  • mms
  • mobile
  • multimedia
  • network
  • OracleVM
  • palm
  • python
  • rokr e6
  • social media networking
  • storage
  • sysadm
  • tablet
  • twitter
  • virtualization
  • wap
  • windows
  • wordpress
  • xen

Copyright © 2025 XceptN’s Tech Stuff.

Powered by PressBook Masonry Dark