Check the presence of file >size?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Check the presence of file >size?
# 1  
Old 09-26-2012
Check the presence of file >size?

Hi,
Following script work fine:
Code:
#!/bin/bash                                                                                                                                           
FILE=$1
if [ -s $FILE]; then
echo Yay
else
echo Boo
fi

But I would like to add another condition that if FILE > 100MB exit??

thanks
# 2  
Old 09-26-2012
Code:
if...; then... ; elif (( $(stat -c %s $FILE) > 104857600 )); then exit; else... ; fi

--
Bye
# 3  
Old 09-26-2012
Thanks Lem..Smilie

---------- Post updated at 03:11 PM ---------- Previous update was at 03:05 PM ----------

Quote:
Originally Posted by Lem
Code:
if...; then... ; elif (( $(stat -c %s $FILE) > 104857600 )); then exit; else... ; fi

--
Bye
Hi,
I was trying to plugged in like this:
Code:
#!/bin/bash                                                                                                                                           
FILE=$1
if [ -s $FILE && ( $(stat -c %s $FILE) > 104857600 ) ]; then
echo Yay
else
echo Boo
fi


Did not work..
# 4  
Old 09-26-2012
Code:
if [ -s $FILE ] && (( $(stat -c %s $FILE) > 104857600 )); then

--
Bye
This User Gave Thanks to Lem For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File size check

I am trying to check whether two files are empty or not using below if condition but its checking for only one file if ] Again I tried if && ] Need your assistance (2 Replies)
Discussion started by: Aditya_001
2 Replies

2. Shell Programming and Scripting

Check file presence and delete other file

Hello, I have file all_file.txt at the end of process this file all_file.txt should be deleted only if there is no file present in dir /all_file/tmp/ or in it's sub directory. can you please help me with the peace of code for this. Thanks (2 Replies)
Discussion started by: kumar30213
2 Replies

3. Shell Programming and Scripting

Check presence of trigger file

Hi, I make a sftp connection successfully.My requirement is the script shall execute only after i find a trigger file(dailyreport.OK.psv) in the remote dir. If the trigger file is not present ,the script should exit else it should continue with the rest of the scripts statements. Below code is... (13 Replies)
Discussion started by: samrat dutta
13 Replies

4. Shell Programming and Scripting

Check a file size

I'm doing a script thats check if mylogfile.log is bigger then 5000 but i dont know how to write it. thanks in avance. (6 Replies)
Discussion started by: Froob
6 Replies

5. Shell Programming and Scripting

check file for presence of set of strings

hi everybody, I need a quick help with this issue. I have configuration file in which the following set of strings must be present. I need to check it with the bash script (leading spaces are not significant). Check must be case insensitive. Can anybody help? ... any lines <SECTION... (4 Replies)
Discussion started by: sameucho
4 Replies

6. OS X (Apple)

command to check presence of volume

Hi: I'm not really a programmer, but I've created a small logout hook script to copy some specific directories to a server volume when a user logs out (10.6.4). These is a laptop user, so I'm looking find: 1) the command to check if the volume (including path to directory?) is available. ... (1 Reply)
Discussion started by: kevinmmac
1 Replies

7. Shell Programming and Scripting

Check the file size - help

I want to write a batch job (ksh) with the following requirement we have file feeds coming to our system from other team, if the file size is greater than expected then we dont need to process the file for the day and need to archive the file and send email notification to the manager saying... (5 Replies)
Discussion started by: sithara
5 Replies

8. Shell Programming and Scripting

check presence of input file

My script is taking a file "input.in" as input for running the script. My worry is that i need to execute the script only if the file is present, if it's not don't perform the next commands. Just to have a check at the beginning of the script : If "input.in" exists, then go on. If it's does not... (4 Replies)
Discussion started by: newpromo
4 Replies

9. Shell Programming and Scripting

Check for file size is zero or not.

I have following script on AIX/KSH if ] ; then echo "filename exists and is > 0 bytes" else echo "filename does not exist or is zero length" fi It is not working. What is wrong here??? (3 Replies)
Discussion started by: Hangman2
3 Replies

10. Shell Programming and Scripting

To check file size

Hi All, I am in small problem.. i have one script which transfers some big files to my ftp usign normal command like put .... my problem is how to check whether my file have been transferred successfully on ftp or not... i know only inside ftp we have option like 'size' command which... (2 Replies)
Discussion started by: Shahul
2 Replies
Login or Register to Ask a Question