![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to check for empty file in Perl? | deepakwins | UNIX for Dummies Questions & Answers | 1 | 03-04-2008 03:00 PM |
| Check for empty string | rahman_riyaz | Shell Programming and Scripting | 12 | 01-24-2008 03:13 AM |
| Check for Empty Command Argument | Nysif Steve | UNIX for Dummies Questions & Answers | 6 | 09-19-2007 03:59 PM |
| How to check for null or empty string | doer | Shell Programming and Scripting | 5 | 07-24-2007 01:31 AM |
| How can I make the for command check to see if a file is empty before executing? | chrchcol | Shell Programming and Scripting | 3 | 07-29-2006 03:14 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
|||||
|
Quote:
Code:
$ ls $ touch file_1 $ dd if=/dev/zero of=$HOME/tmp/file_2 bs=1 count=100 100+0 records in 100+0 records out $ ls -l file_1 file_2 file_3 ls: file_3: No such file or directory -rw-rw-r-- 1 foo bar 0 Sep 24 20:28 file_1 -rw-rw-r-- 1 foo bar 100 Sep 24 20:28 file_2 $ [[ -s file_1 ]] $ echo $? 1 $ [[ -s file_2 ]] $ echo $? 0 $ [[ -s file_3 ]] $ echo $? 1 ZB |
|
|||||
|
Quote:
![]() |
|
||||
|
this is just another way of doing it
a round about one Code:
if [ `ls -l <file> | awk '{print $5}'` -eq 0 ]
then
//condition for being empty
else
//condition for not being empty
fi
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|