HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- bash: unbound variable
Operating System - HP-UX
1827636
Members
3775
Online
109966
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2002 07:36 PM
12-19-2002 07:36 PM
bash: unbound variable
when I execute a shell script containing:
(and expecting to get one of the two statements echoed)
if [ $greg = "test" ]; then
echo "greg equal to test"
else
echo "greg not equal to test"
fi
I get:
bash: greg: unbound variable
Can anyone explain what's the deal there?
(and expecting to get one of the two statements echoed)
if [ $greg = "test" ]; then
echo "greg equal to test"
else
echo "greg not equal to test"
fi
I get:
bash: greg: unbound variable
Can anyone explain what's the deal there?
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2002 08:02 PM
12-19-2002 08:02 PM
Re: bash: unbound variable
how shell is supposed to find greg? you are defining it anywhere in the script.
It should be
grep=test
if [ $greg = "test" ]; then
echo "greg equal to test"
else
echo "greg not equal to test"
fi
This will give greg eqal to test
It should be
grep=test
if [ $greg = "test" ]; then
echo "greg equal to test"
else
echo "greg not equal to test"
fi
This will give greg eqal to test
There is no substitute to HARDWORK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2002 08:21 PM
12-19-2002 08:21 PM
Re: bash: unbound variable
An unbound variable is one that has not been defined.
Try checking for existence of the variable using the test -z option before doing any comparison:
if [ -z $greg ]; then
....
Try checking for existence of the variable using the test -z option before doing any comparison:
if [ -z $greg ]; then
....

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2002 08:28 PM
12-19-2002 08:28 PM
Re: bash: unbound variable
///define greg//
greg=test
or
greg=test1
if [ $greg = "test" ]
then
echo "greg equal to test"
else
echo "greg not equal to test"
fi
greg=test
or
greg=test1
if [ $greg = "test" ]
then
echo "greg equal to test"
else
echo "greg not equal to test"
fi
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP