Sponsored Content
Top Forums Shell Programming and Scripting unix script to check whether particular file exists and to find its size Post 302164473 by Balachandar on Tuesday 5th of February 2008 02:09:11 AM
Old 02-05-2008
compile time error when i execute this code

Hi all,
Please tell me to solve this issue,

ROTATE_FILES=" <PATH>"
REAL_FILE="MQ.log"

function rotate_files()
{
for j in $1;do
echo "Loop1"

if [ -d $j ]
then
for i in `ls -a /$j`
do

if [ $i = MQ.log ]
then
echo $i

FILESIZE=`ls -l $i|awk '{print $5}'` #......error......#
LIMIT=0

if [ $FILESIZE -ge 0 ] #......error......#
then
echo "the size is greater"
fi

fi

done
fi
done
}

rotate_files "$ROTATE_FILES"

-----------------------------------------------------------------

FILESIZE=`ls -l $i|awk '{print $5}'`
"ls: MQ.log: No such file or directory" <<<error message

if [ $FILESIZE -ge 0 ]
"[: -ge: unary operator expected" <<<error message

please tell me how to solve this
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check File Exists and compare to previous day file script

We have data files that are ftp'd every morning to a SUN server. The file names are exactly the same except for that each has the date included in its name. I have to write script to do 2 things: STEP 1) Verify that the file arrived in morning. STEP 2) Compare the file size of the current... (3 Replies)
Discussion started by: rbknisely
3 Replies

2. Shell Programming and Scripting

Need to write a script in UNIX to find a file if another file exists

So I have a lot of Java applications on my servers all having their own folder from the applications subdirectory. Now, I need to do the following. Search all the applications subdirectories for message.jar. If the message.jar file exists, I need to search the application directory for... (1 Reply)
Discussion started by: mmdawg
1 Replies

3. Shell Programming and Scripting

Command/script to find size of Unix Box ?

Please could anyone provide me the Command/script to find the size and usage of Unix box ASAP ? (6 Replies)
Discussion started by: sakthifire
6 Replies

4. UNIX for Advanced & Expert Users

how to find the file size in unix

Anybody can help HOW TO FIND THE FILE SIZE IN UNIX (5 Replies)
Discussion started by: lmraochodisetti
5 Replies

5. Shell Programming and Scripting

Shell script to check if any file exists in 4 folders

Hi All, working on AIX 5.3. Requirement is: Shell script in ksh to check if any file exists in 4 folders as below: 1. /FILE/INB/INT1 2. /FILE/INB/INT2 3. /FILE/INB/INT3 4. /FILE/INB/INT4 Thanks a lot for your time! a1_win. (3 Replies)
Discussion started by: a1_win
3 Replies

6. Shell Programming and Scripting

Script to check if file exists

guys, I am trying to write a script that does the following: it looks for a file in a specific directory and if the file is not there (NOT), it emails me. I have tried the following but its not working. It simply hangs up. Please help. if then mail -s 'blah blah blah' my email... (4 Replies)
Discussion started by: basisvasis
4 Replies

7. Shell Programming and Scripting

Script to check for the file existence, if file exists it should echo the no of modified days

Hi, I am looking for a shell script with the following. 1. It should check whether a particular file exists in a location #!/bin/sh if ; then echo "xxx.txt File Exists" else echo "File Not Found" fi 2. If file exists, it should check for the modified date and run a command... (2 Replies)
Discussion started by: karthikeyan_mac
2 Replies

8. Shell Programming and Scripting

Script to check file exists

Hi, I am trying to write a script which checks if any file exists with "*.log" or "*.out" in Directory below is the code #------------------ path=/abd/xyz/ if ; then echo "Good" else echo "Failure" fi #-------------------------- its always going to else part and printing... (8 Replies)
Discussion started by: ch33ry
8 Replies

9. Shell Programming and Scripting

Except script fails to check file exists or not in remote node

Dear members, The following expect script connects to remote node and check for the file "authorized_keys" in directory /root/.ssh in remote node. However the result is always found even if the file exist or doesn't exist. expect { "$fname" { send_user "found\n" } Any idea what is... (4 Replies)
Discussion started by: Sudhakar333
4 Replies

10. Shell Programming and Scripting

Shell script which will check the target file and folder exists and copy it

Hi All, I am a beginner in this and trying to write a shell script in linux which will : 1. Ask for a file name and check if its exists. 2. If file exists only then it will ask for the new target folder, after entering target folder name it will check if it exists. 3. If target folder... (3 Replies)
Discussion started by: ashish_neekhra
3 Replies
BPING(1)							  BP executables							  BPING(1)

NAME
bping - Send and receive Bundle Protocol echo bundles. SYNOPSIS
bping [-c count] [-i interval] [-p priority] [-q wait] [-r flags] [-t ttl] srcEID destEID [reporttoEID] DESCRIPTION
bping sends bundles from srcEID to destEID. If the destEID echoes the bundles back (for instance, it is a bpecho endpoint), bping will print the round-trip time. When complete, bping will print statistics before exiting. It is very similar to ping, except it works with the bundle protocol. bping terminates when one of the following happens: it receives the SIGINT signal (Ctrl+C), it receives responses to all of the bundles it sent, or it has sent all count of its bundles and waited wait seconds. EXIT STATUS
These exit statuses are taken from ping. 0 bping has terminated normally, and received responses to all the packets it sent. 1 bping has terminated normally, but it did not receive responses to all the packets it sent. 2 bping has terminated due to an error. Details should be noted in the ion.log log file. FILES
No configuration files are needed. ENVIRONMENT
No environment variables apply. DIAGNOSTICS
Diagnostic messages produced by bping are written to the ION log file ion.log and printed to standard error. Diagnostic messages that don't cause bping to terminate indicate a failure parsing an echo response bundle. This means that destEID isn't an echo endpoint: it's responding with some other bundle message of an unexpected format. Can't attach to BP. bpadmin has not yet initialized Bundle Protocol operations. Can't open own endpoint. Another application has already opened ownEndpointId. Terminate that application and rerun. bping bundle reception failed. BP system error. Check for earlier diagnostic messages describing the cause of the error; correct problem and rerun. No space for ZCO extent. ION system error. Check for earlier diagnostic messages describing the cause of the error; correct problem and rerun. Can't create ZCO. ION system error. Check for earlier diagnostic messages describing the cause of the error; correct problem and rerun. bping can't send echo bundle. BP system error. Check for earlier diagnostic messages describing the cause of the error; correct problem and rerun. BUGS
Report bugs to <ion-bugs@korgano.eecs.ohiou.edu> SEE ALSO
bpecho(1), bptrace(1), bpadmin(1), bp(3), ping(8) perl v5.14.2 2012-05-25 BPING(1)
All times are GMT -4. The time now is 03:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy