- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- scripting question -
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
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
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
06-25-2012 10:24 AM
06-25-2012 10:24 AM
scripting question -
Hi ,
I am trying to check if files are present inside the directory or not, but getting error, not sure if the syntax is correct,
if [ -f /home/myfiles/* ]
then
echo "files found "
else
echo "files not found"
##########################
can you guys advise, whats wrong
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2012 12:03 PM - edited 06-25-2012 07:26 PM
06-25-2012 12:03 PM - edited 06-25-2012 07:26 PM
Re: scripting question (empty directory)
-f only works on one file at a time. You need to use something like:
if [ ! -z $( ls /home/myfiles 2> /dev/null ) ]; then
echo "files found"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2012 02:11 PM
06-25-2012 02:11 PM
Re: scripting question -
Dennis,
Thanks,
what is the -z is stands for. is it checking for zero byte,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2012 07:26 PM
06-25-2012 07:26 PM
Re: scripting question (empty directory)
>what is the -z is stands for. Is it checking for zero byte,
You can look at the man ages for test(1), ksh(1) or sh-posix(1).
This is if the string has zero length and "! -z" means not empty.