check whether 3 files are present


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting check whether 3 files are present
# 1  
Old 03-23-2009
check whether 3 files are present

I'm trying to check whether 3 files are existing and send 3 files as attachements.
If only two are there then send those two files as attachments.

if [ -s "ESSKPI" && -s "ESSORG" && -s "ESSROLE"]; then
elif [ -s "ESSKPI" && -s "ESSORG"]; then
I tired the above given syntax and then it is giving me an error
line 11: [: missing `]'

I tried with -a instead of && and that is also not working.

When i tried

if [ -s "ESSKPI"] && [-s "ESSORG" && -s "ESSROLE"]; then
elif [ -s "ESSKPI"] && [-s "ESSORG"]; then

This one is hanging and not doing anything.

Can somebody please help me with this?
# 2  
Old 03-23-2009
it got resolved....
# 3  
Old 03-23-2009
I hope this will help you .....

I hope this will help you .....
just check with the square braces i hope this should work in your env
try to use {} in place of [] if it doesnt works


#!/bin/ksh

file1=/home/scott/a.txt
file2=/home/scott/b.txt
file3=/home/scott/c.txt


## -f is used for <file exists >

##verify whether there exist 3 files if it is true then send the files via attachement

IF [ ( -f $file1 ) -a ( -f $file2 ) -a ( -f $file3 ) ]

THEN



(uuencode $file1 $file1 ; uuencode $file2 $file2; uuencode $file3 $file3 ) |mailx -m -s "attachements" a@aol.in




##verify whether there exist 2 files if it is true then send the files via attachement


ELIF [ ( -f $file1 ) -a ( -f $file2 ) ]

(uuencode $file1 $file1 ; uuencode $file2 $file2) |mailx -m -s "attachements" a@aol.in


fi

Last edited by palanisvr; 03-23-2009 at 11:07 AM..
# 4  
Old 03-23-2009
Hi Palanisvr

I tried if [[ -s "$ESS_KPI_ERR" ]] && [[ -s "$ESS_ORG_ERR" ]] && [[ -s "$ESS_ROLE_ERR" ]]; then and it worked.

Thanks a lot for oyur help.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unzip all the files with subdirectories present and append a part of string from the main .zip files

Hi frnds, My requirement is I have a zip file with name say eg: test_ABC_UH_ccde2a_awdeaea_20150422.zip within that there are subdirectories on each directory we again have .zip files and in that we have files like mama20150422.gz and so on. Iam in need of a bash script so that it unzips... (0 Replies)
Discussion started by: Ravi Kishore
0 Replies

2. Shell Programming and Scripting

To Tar files which are not present

Hi guys, I need how its possible to tar group of files even though the respective file is not present for eg in my home folder my script looks like below by reading the content from file.txt and creating tar out of it can any one help on the below query a=`more file.txt` tar -cvf... (6 Replies)
Discussion started by: rohit_shinez
6 Replies

3. Shell Programming and Scripting

Compare two numbers which present in two different files

Hi, I need to compare the two floating or integer numbers which present in two different files, Ex: File 1: col1 col2 col3 11 ssa 13.60 12 ssb 11.00 13 ssc 754.00 File 2:col1 col2 col3 11 sa 12.75 12 sb 11.00 13 sc 763.00 here i have to compare 3 column if 1st column match,... (8 Replies)
Discussion started by: Shenbaga.d
8 Replies

4. Shell Programming and Scripting

Checking in a directory how many files are present and basing on that merge all the files

Hi, My requirement is,there is a directory location like: :camp/current/ In this location there can be different flat files that are generated in a single day with same header and the data will be different, differentiated by timestamp, so i need to verify how many files are generated... (10 Replies)
Discussion started by: srikanth_sagi
10 Replies

5. Shell Programming and Scripting

List all the files in the present path and Folders and subfolders files also

Hi, I need a script/command to list out all the files in current path and also the files in folder and subfolders. Ex: My files are like below $ ls -lrt total 8 -rw-r--r-- 1 abc users 419 May 25 10:27 abcd.xml drwxr-xr-x 3 abc users 4096 May 25 10:28 TEST $ Under TEST, there are... (2 Replies)
Discussion started by: divya bandipotu
2 Replies

6. Shell Programming and Scripting

How to Check whether list file present in TXT file exist or not

Hi All, I have txt file which has list of files. I have to check whether these files exist or not. Thanks supriya (6 Replies)
Discussion started by: supriyabv
6 Replies

7. Shell Programming and Scripting

How to check the variable is present in array or not ?

Hi , I am trying to check wether the variable is present in the array. please see the below code .when ever i do this its taking only the first value of the array . please advise. ###Code Snnipet ### #!/bin/ksh set -xv if ]; then echo " you have Specified the ORG ID - $1 " ... (1 Reply)
Discussion started by: padhu.47
1 Replies

8. Shell Programming and Scripting

Check whether the pattern is present or not?

I want to determine whether a specific pattern is present within a line or not e.g. The whole line is in a varaible called VALUE VALUE="(ABC, DEF, NMF, ABC, CLF, PAR, FHG, AGQSAs, sada, sa, ABC)" i want to set a flag to 1 if i find the presence of ABC in the above variable. Please... (8 Replies)
Discussion started by: skyineyes
8 Replies

9. UNIX for Dummies Questions & Answers

how to check if path is present?

following situation... - bourne shell script - sb. should entry a path and the script should look if the path exists, when not it should restart the Input ... echo "path\c" read Inp if ; then echo " path doesn't exist, try again... " (how to go back to the Inp?????) else echo "... (3 Replies)
Discussion started by: svennie
3 Replies
Login or Register to Ask a Question