HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Shell script: how to check whether a directory...
Operating System - HP-UX
1835041
Members
2162
Online
110073
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
Go to solution
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
10-18-2002 06:24 AM
10-18-2002 06:24 AM
I'm writing a shell script that checks the read/write permission of a file. I encounter some problems of the if-else statement which consists of some syntax errors. What's wrong with my shell programming?
---------------
#!/bin/sh
echo "Enter a file: \c"
read file
if [ -r "$file -a -w "$file" ]
then
echo "$file is readable and writable."
elif [ -r "$file" -a ! -w "$file" ]
then
echo "$file is readable but not writable."
else
echo "$file is not readable and not writable"
fi
---------------
The script is supposed to read a file from user and then checks whether it is readable or writable. How do I correct my errors?
---------------
#!/bin/sh
echo "Enter a file: \c"
read file
if [ -r "$file -a -w "$file" ]
then
echo "$file is readable and writable."
elif [ -r "$file" -a ! -w "$file" ]
then
echo "$file is readable but not writable."
else
echo "$file is not readable and not writable"
fi
---------------
The script is supposed to read a file from user and then checks whether it is readable or writable. How do I correct my errors?
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2002 06:38 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2002 12:39 AM
10-21-2002 12:39 AM
Re: Shell script: how to check whether a directory is empty?
I am curious as the difference between the title of your post and the problem you describe therein. Have you solved the problem described by the title?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2002 04:00 AM
10-21-2002 04:00 AM
Re: Shell script: how to check whether a directory is empty?
Martin,
The title of this post is the same as another post from cybermilky on the same day. Must have forgotten to change the title on this one.
Theresa
The title of this post is the same as another post from cybermilky on the same day. Must have forgotten to change the title on this one.
Theresa
This is my easy job!
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
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP