Can I find wether a particular file exist and size greater than zero...help please


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Can I find wether a particular file exist and size greater than zero...help please
# 1  
Old 11-23-2005
Data Can I find wether a particular file exist and size greater than zero...help please

Can I find wether a particular file exist and size greater than zero in one line command.

similar to this

if [-f *.log] && [ -s *.log]

something in one if test .... e.g. if [-f -s ????]

1.) is it possible ? ... if yes how

2.) what would be the return type in case there is success or failure. I mean if both are true or any one is true
# 2  
Old 11-23-2005
# 3  
Old 11-23-2005
According to Oreilly's "UNIX in a Nutshell,":

Quote:
-s file
file exists and has a size greater than zero.
So all you need is the -s.
# 4  
Old 11-28-2005
can i find the size of the file ! ....

Quote:
Originally Posted by Abhishek Ghose
***********************
hi ...

what i mean is here below
I have a folder which have files + sub folders (which in turn contain files). The files in foder or sub folder might be empty or size greater than zero. now if I use TEST then it is only going to find the files in the curent folder. but it will not give me the information about the files inside the sub folder.

now how can i get the information of both the files present inside folder or subfolder wether they are greater than zero or not ( empty or not)

Thanks for ur co-operation .. looking forward for the reply

****************************************
# 5  
Old 11-28-2005
find . -type f ! -size 0 -exec ls -l {} \;
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Find command size greater than or equalto

How do I find the files greater than or equal to a given size using find command. find ./ -size +0k --> Lists files greater than 0K find ./ -size 0k --> Lists the file size equal to 0K. I have other conditions to check, hence using find command. Thanks in advance. (4 Replies)
Discussion started by: deepakwins
4 Replies

2. UNIX for Dummies Questions & Answers

look for file size greater than "0" of specific pattern and move those to another directory

Hi , i have some files of specific pattern ...i need to look for files which are having size greater than zero and move those files to another directory.. Ex... abc_0702, abc_0709, abc_782 abc_1234 ...etc need to find out which is having the size >0 and move those to target directory..... (7 Replies)
Discussion started by: dssyadav
7 Replies

3. UNIX for Dummies Questions & Answers

How to find if file exist in directory using *

Hi, I know how to use the test command ( ...) to find a single given name file. However, I have a case in which I have a directory with one file and one sub-directory. I know that the file starts with "fub". The command doesn't work if i call the file "fub*" as it doesn't understand I meant a... (2 Replies)
Discussion started by: buj
2 Replies

4. Shell Programming and Scripting

Unix file empty.. but size is greater than zero??/

Hi, I have a file by redirecting some contents in unix shell. Even when there is no content that is being redirected, the file size still shows greater than zero. but even if there is no matching pattern the file APPRES has size greater than 0bytes. awk -f AA.awk $logfile>APPRES... (3 Replies)
Discussion started by: justchill
3 Replies

5. Shell Programming and Scripting

shell script to check file size greater than 50M

Hi All, OS:AIX 64 bits using korn shell. Requirement: shell script to check file size greater than 50M and send mail alert. Thanks for your time! Regards, (3 Replies)
Discussion started by: a1_win
3 Replies

6. Shell Programming and Scripting

Filter the file list greater then the size specified by user

HI, Can any tell me how to filter the list of files greater than the size specified by user. The size should be provided by user as an input. Regards shiva (6 Replies)
Discussion started by: shivu
6 Replies

7. Solaris

command to find out total size of a specific file size (spread over the server)

hi all, in my server there are some specific application files which are spread through out the server... these are spread in folders..sub-folders..chid folders... please help me, how can i find the total size of these specific files in the server... (3 Replies)
Discussion started by: abhinov
3 Replies

8. Shell Programming and Scripting

Find lines greater than 80 characters in a file

Hi, Can anyone please give me the grep command to find all the lines in a file that exceed 80 columns Thanks, gubbala (8 Replies)
Discussion started by: mrgubbala
8 Replies

9. UNIX for Dummies Questions & Answers

Find in file. Does this exist under UNIX?

Hello, I have the following problem. I know there is a file somewhere on a UNIX machine that contains a string, but I don't know where. With the "grep" command, I can look into a file but only if I'm located in the correct directory. With the "find" command, I can search across directories... (2 Replies)
Discussion started by: scampsd
2 Replies

10. Shell Programming and Scripting

File size greater than 0

ok I want to know how to touch a file and find out that it is greater than 0 then if it is not I want to fail the job other wise I want to success amnd go on. Can anyone help. Thanks Shannon Kammer (1 Reply)
Discussion started by: skammer1234
1 Replies
Login or Register to Ask a Question