![]() |
|
|
|
|
|||||||
| 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 |
| AWK help please - beginner | COLLEGE | UNIX for Dummies Questions & Answers | 4 | 06-13-2007 04:40 AM |
| Beginner C | frustrated1 | High Level Programming | 2 | 05-21-2007 11:14 AM |
| FTP - To handle error while transferring files | mahalakshmi | Shell Programming and Scripting | 1 | 04-04-2007 12:56 AM |
| Can solaris's Zip/Unzip handle Winzip Version 10.0 Files? | BCarlson | UNIX for Dummies Questions & Answers | 2 | 08-24-2006 10:44 PM |
| Please help. I am a beginner. | Lykathea Aflame | Shell Programming and Scripting | 1 | 04-25-2006 10:46 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi,
How can I check if a text files is empty? (With Bash Shell) |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
[ -s file ] && echo "File is not empty" || echo "File is empty"
|
|
#3
|
|||
|
|||
|
Quote:
but can I do it in another way? |
|
#4
|
||||
|
||||
|
[ `cat file | wc -l` -gt 0 ] && echo "Not empty" || echo "empty"
|
|
#5
|
|||
|
|||
|
Code:
if [ -s file ] then echo "File is not empty" else echo "File is empty" fi Code:
if [[ -s file ]] then echo "File is not empty" else echo "File is empty" fi |
|
#6
|
|||
|
|||
|
thank you everybody
|
|||
| Google The UNIX and Linux Forums |