Computing.Net > Forums > Unix > find command problem

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

find command problem

Reply to Message Icon

Name: spikey
Date: August 2, 2003 at 20:25:03 Pacific
OS: UNIX
CPU/Ram: Intel
Comment:

I always get true for the following if condition. I am probably stating the condition in a wrong way. Can some help me fix the if condition.
The following is the script I use. Platform is Unix.

#!/bin/bash
if [ $"(find /myfiles/program1 -newer program2)" ];then
{
echo "Older";
}
else
{
echo "Newer";
}
fi



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: August 3, 2003 at 12:19:27 Pacific
Reply:

Hi:

eliminate the double quotes:

if [ $(find a.sh -newer check.ftp) ];then

Regards,

Nails


0

Response Number 2
Name: WilliamRobertson
Date: August 3, 2003 at 14:04:29 Pacific
Reply:

And the brackets if you feel like it:

if find a.sh -newer check.ftp >&-
then



0

Response Number 3
Name: ArnoldF
Date: August 3, 2003 at 17:11:09 Pacific
Reply:

on linux, test(1) includes
FILE1 -nt FILE2
FILE1 is newer (modification date) than FILE2

man test - if OK:
if [ a.sh -nt check.ftp ]
then


0

Response Number 4
Name: Frank
Date: August 4, 2003 at 00:10:24 Pacific
Reply:

otherwise you should use the file name variable indicator.

find . -name "file" -newer "file2"

Cheers Frank


0

Response Number 5
Name: spikey
Date: August 4, 2003 at 18:34:51 Pacific
Reply:

Thank you guys, I tried the -nt method and it works fine for me.


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: find command problem

Using find command www.computing.net/answers/unix/using-find-command-/2853.html

Limiting the find command www.computing.net/answers/unix/limiting-the-find-command/6637.html

find command - korn shell www.computing.net/answers/unix/find-command-korn-shell/5568.html