- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: test wheather at least one file exists
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
Forums
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
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-02-2003 12:37 AM
05-02-2003 12:37 AM
When there is more then one file this failed on linux:
if [ -f /folder/fileprefix*.filesuffix ]
there is no problem with the syntax in HP-UX (ksh). Can you help me with the syntax?
Thanks,
Andrej
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2003 01:24 AM
05-02-2003 01:24 AM
Re: test wheather at least one file exists
http://www.experts-exchange.com/Programming/Programming_Platforms/Unix_Programming/Q_20494418.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2003 01:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2003 06:51 AM
05-02-2003 06:51 AM
Re: test wheather at least one file exists
then
echo "do something"
else
echo "didn't find the file"
fi
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2003 11:07 PM
05-02-2003 11:07 PM
Re: test wheather at least one file exists
You'll find on most Unix systems that the [ is a symboilc link to the program 'test' (but not all).
'ksh' does do some fun things with scripts. Unforunately 'ksh' (pdksh) on Linux does not behave in the exact same manner has 'ksh' on HP-UX (or SCO OSR which is what I was toying with).
To achive what you are wanting to do, you'll have to resort to doing something like:
if [ "$(echo *.blah)" != "*.blah" ]
A strange work around, and admittadly not the best check (will match directories as well as symoblic links).
You could always write your own shell function which looped through + counted arguments..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2003 04:20 AM
05-05-2003 04:20 AM
Re: test wheather at least one file exists
if [ -f /home/name/file ]
to test for a directory do:
if [ -d /home/directory ]
to test for file permissions do:
if [ -r file ]
if [ -w file ]
if [ -x file ]
to test if user owns a file do:
if [ -O file ] #capital letter o
to test if a file exists and is non-empty do:
if [ -s file ]
to test if sticky bit is set do:
if [ -k file ]
to test if it is a symbolic link do:
if [ -L file ]
to test if user is in the same group do:
if [ -G file ]
There are several other "if" tests but I think this should cover almost any of your needs.