GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   In a shell script.. how do I test if any *.php exist? (https://gfy.com/showthread.php?t=896557)

Tempest 03-29-2009 01:13 AM

In a shell script.. how do I test if any *.php exist?
 
if test -e *.php; is invalid so how do you do that?

kmanrox 03-29-2009 01:17 AM

my techs arent around, but if you mean search for .php the comman is locate *.php

Tempest 03-29-2009 01:27 AM

not to search.. to check if any exists and branch in the script based on it.

rowan 03-29-2009 03:32 AM

Maybe something like...

if [ "`ls *.php`X" = "X" ]; then
# no *.php
fi


That may print out an error to stderr if there's no files. Not sure.

I wouldn't use 'locate' since that checks the locate database (which is only rebuilt periodically) rather than looking at actual (current) directory entries.

Pixelbucks Eric 03-29-2009 08:38 AM

if [ -f *.php ]; then echo "PHP files present"; fi

Mind you, the spaces need to be there.
Also, you could do:

if [ ! -f *.php ]; then echo "no PHP files present"; fi

sortie 03-29-2009 10:33 AM

Quote:

Originally Posted by Tempest (Post 15684651)
if test -e *.php; is invalid so how do you do that?

Let me guess......you got hacked and you have cheap hosting
and the host thinks the problem is you.

:1orglaugh


Just a WILD guess here.

Tempest 03-31-2009 01:20 AM

Quote:

Originally Posted by sortie (Post 15685316)
Let me guess......you got hacked and you have cheap hosting
and the host thinks the problem is you.

:1orglaugh

Just a WILD guess here.

No.. setting up a script to do an auto update of data files and need to do a cleanup.

2012 03-31-2009 01:30 AM

Quote:

Originally Posted by sortie (Post 15685316)
Let me guess......you got hacked and you have cheap hosting
and the host thinks the problem is you.

:1orglaugh


Just a WILD guess here.

:1orglaugh what dick you are :1orglaugh

2012 03-31-2009 01:31 AM

Quote:

Originally Posted by Tempest (Post 15690990)
No.. setting up a script to do an auto update of data files and need to do a cleanup.

sounds like you just need this ... http://www.amazon.com/Linux-Command-.../dp/047025128X

rowan 03-31-2009 05:28 AM

Quote:

Originally Posted by Pixelbucks Eric (Post 15685125)
if [ -f *.php ]; then echo "PHP files present"; fi

Mind you, the spaces need to be there.
Also, you could do:

if [ ! -f *.php ]; then echo "no PHP files present"; fi

Might also need to quote "*.php"


All times are GMT -7. The time now is 06:53 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc