![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| C function to test existence of a login | xavier054 | High Level Programming | 2 | 03-04-2008 09:51 AM |
| Checking the existence of a file.. | igandu | Shell Programming and Scripting | 7 | 06-13-2007 12:47 AM |
| File existence | mpang_ | Shell Programming and Scripting | 2 | 03-27-2006 08:27 AM |
| How to test for a specific file size | GEBRAUN | UNIX for Dummies Questions & Answers | 1 | 02-20-2006 07:50 AM |
| Loop for file existence | bd_joy | UNIX for Dummies Questions & Answers | 2 | 02-02-2006 08:51 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
how to test for file existence using file size?
ok im doing this in a normal shell. i need to check the file in the script. how should i write the if else statment?
if the filesize contains 0kb then it will echo out file contains nothing else if the script contains more than 0kb then it will echo out file exist. any one care to help? thanks ! im new to unix scripting.. |
| Forum Sponsor | ||
|
|
|
|||
|
Here's something a little more informative, if you need it, but it's in ksh. Dunno if that's normal enough for you. -e is not available in sh:
#!/bin/ksh if [ -s /path/to/file ] ; then echo We have a file with stuff in it elif [ -e /path/to/file ] ; then echo We have a file with 0-length else echo "The file isn't even there!" fi do a "man test" on a UNIX box near you. BTW, if you're on Linux then /sbin/sh is likely really bash, and you can use the -e. |
|||
| Google The UNIX and Linux Forums |