Need help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help
# 1  
Old 11-21-2011
Need help

Hi,

I have three files abc.dat,def.dat,xyz.dat.

I have a shell script child.ksh which I should run only when any of the above three files exist. Can you please let me know how can i achive this?

I have given a try like this.

Code:
if [ -e abc.dat -o -e def.dat -o -e xyz.dat ]; then
child.ksh
fi

but this is giving an syntax error


please suggest.

Thanks
Moderator's Comments:
Mod Comment
Please use code tags when posting data and code samples!

Last edited by vgersh99; 11-21-2011 at 12:11 PM.. Reason: code tags, please!
# 2  
Old 11-21-2011
Giving which syntax error?

You may need to run child.ksh as ./child.ksh if its in the current directory.

What's your system?

What's your shell?

Never make threads titled "need help". Title them what your question is.
# 3  
Old 11-21-2011
I am using ksh... when I try with one file, -e oprion is working fine. but when I am trying with multiple files its now working.
The error is test: syntax error
# 4  
Old 11-21-2011
The code works just fine in my shell. Can't tell why it's not working in yours unless the error actually happens in code you didn't post.

Since you have ksh, you can do this:

Code:
if [[ -e file1 || -e file2 || -e file3 ]]; then ...

which may work better.
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question