• Advertisement
Sign in to follow this  

bash scripting question

This topic is 4786 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have virtually no idea how to do this, and I have spent ages googling (I have tried).
	if [ fexist $1 ]; then
		if [ file_date $1 -gt $someotherfile ]; then
			# ...
		fi
	fi
Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Genjix
I have virtually no idea how to do this, and I have spent ages googling (I have tried).

if [ fexist $1 ]; then
if [ file_date $1 -gt $someotherfile ]; then
# ...
fi
fi

Thanks.


I might help if you explained what you are trying to do.

Share this post


Link to post
Share on other sites

if file exists
{
if files date > someotherfile
{
do stuff
}
}

sorry, but I don't really know how to phrase it.

Share this post


Link to post
Share on other sites
you could use the -nt or -ot for conditional expressions, i.e.


#file exist?
if [ -f $1 ]; then
if [ $1 -nt somefilename ]; then
#file is newer(based on modification date) than somefilename
fi
fi

Share this post


Link to post
Share on other sites

Oh WOW, simply amazing. Thanks :D. Didn't know that kind of stuff would be built into sh.



[Edited by - Genjix on January 16, 2005 6:52:37 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement