- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- how to compare a null string in UNIX Shell
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
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
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- 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
тАО05-22-2004 05:03 PM
тАО05-22-2004 05:03 PM
how to compare a null string in UNIX Shell
I need to compare a null string comparison like this:
if [ ${STAT} -ne 0 -o
"${file_date}" = " " ]; then
echo "file date is NULL"
fi
But my code is not working. ${STAT} is the exit status.
Please suggest me what am I doing wrong.. Thank You,
Suman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2004 05:25 PM
тАО05-22-2004 05:25 PM
Re: how to compare a null string in UNIX Shell
and if you have your shell patched with recent patches the proper syntax would be:
if (( $STAT} != 0 )) || [[ -z "${file_date}" ]] ;then
print "file date is null"
fi
[...] and echo are obsolete
and if you just want an error message
print ${file_date:?}
will do that for you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2004 06:50 PM
тАО05-22-2004 06:50 PM
Re: how to compare a null string in UNIX Shell
-z is what I use too.
I believe, Curt intended to write
if [[ ${STAT} != 0 ]] || [[ -z "${file_date}" ]] ;then
print "file date is null"
fi
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-23-2004 12:59 AM
тАО05-23-2004 12:59 AM
Re: how to compare a null string in UNIX Shell
if I do [[ -z "${file_date}" ] the program is till thinking that the file date is null.
Please tell what am I doing wrong here?
Thank You
Suman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-23-2004 01:16 AM
тАО05-23-2004 01:16 AM
Re: how to compare a null string in UNIX Shell
Thank You for your help.
Suman