| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

08-19-10, 07:39
|
|
Registered User
|
|
Join Date: Aug 2010
Posts: 5
|
|
|
find: invalid switch
|
|
hi,
i have a script that includes the following:
dir1='D:\Program Files\archive'
for Dir in "$dir1"
do
cd "$Dir"
echo `pwd`
find `pwd` -mtime +60 -type f {} \;
done
exit 0
then this is the logs:
+ dir1=D:\Program Files\archive
+ cd 'D:\Program Files\archive'
++ pwd
+ echo /cygdrive/d/Program Files/archive
++ pwd
+ find /cygdrive/d/Program Files/archive -mtime +60 -type f '{}' ';'
FIND: Invalid switch
+ exit 0
why do i have such "invalid switch"? please help...thanks!!!
|
|

08-19-10, 07:43
|
|
Registered User
|
|
Join Date: Aug 2010
Posts: 5
|
|
the scrip is located in a remote server where there is cygwin and i'm trying to use bash...
|
|

08-19-10, 08:52
|
|
:-)
|
|
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,233
|
|
|
|
It seems to be calling the Windows version of "find"; you will need to provide the full path to the cygwin's "find".
|
|

08-19-10, 15:26
|
|
Registered User
|
|
Join Date: Sep 2009
Location: Ontario
Posts: 526
|
|
Or possibly modify your PATH statement so that cygwin is searched before Windows.
|
|

08-19-10, 16:37
|
|
Registered User
|
|
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,413
|
|
|
man find
This is invalid syntax:
Code:
Here >-----------------------------------------------------+----+
V V
find /cygdrive/d/Program Files/archive -mtime +60 -type f '{}' ';'
man find

__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
|
|

08-20-10, 00:02
|
|
Registered User
|
|
Join Date: Aug 2010
Posts: 5
|
|
hi n i and kitaman,
do you mean i should put these as first statements in my scrip??>
#!/cygdrive/c/cygwin/bin/bash -x
#!/cygdrive/c/cygwin/bin/find -x
im just new in unix and scripting... how can i do such providing of full path to cygwin???
hi lkbrwn dba
my syntax is
find `pwd` -mtime +60 -type f {} \;
'{}' ';' >>> are just in the log message... anyway, is there anything wrong with my syntax of 'find' above????
hi all!!!
thanks for the replies... thanks much!!! ive read about find command and the "man" says when there's no path provided, the default path is the current pwd so i tried
find * -mtime +60 -type f {} \; >>>> there was an error: Find parameter incorrect
i also tried
find -mtime +60 -type f {} \; >>>> there was the same error: Find parameter incorrect
|
|

08-20-10, 11:12
|
|
Registered User
|
|
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,413
|
|
Man find!!!
Did you check out the syntax of find in the manual?
Try this and see what happens:
Code:
find `pwd` -mtime +60 -type f -exec cksum {} \;

__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
|
|

08-23-10, 01:55
|
|
Registered User
|
|
Join Date: Aug 2010
Posts: 5
|
|
hi lkbrwn_dba,
i have read before the find man page, it says if no -exec is provided then the default -exec is -print... Anyways, ive tried ur
find `pwd` -mtime +60 -type f -exec cksum {} \;
still there's the same error......... please help me! 
|
|

08-23-10, 11:28
|
|
Registered User
|
|
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,413
|
|
cygwin is a bash.
Quote:
Originally Posted by maxtodoscripts
the scrip is located in a remote server where there is cygwin and i'm trying to use bash...
|
Ok cygwin is another animal...
Try this:
Code:
dir1='Program Files/archive'
cd D:
find "$dir1" -mtime +60 -type f
exit 0
The issue is the space in the name of the "Program Files" directory.

__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
|
Last edited by LKBrwn_DBA; 08-23-10 at 11:57.
Reason: New script
|

08-26-10, 04:00
|
|
Registered User
|
|
Join Date: Aug 2010
Posts: 2
|
|
Please Try below:-
dir1="D:\Program Files\archive"
for Dir in "$dir1"
do
cd "$Dir"
echo `pwd`
find `pwd` -mtime +1 -type f -print
done
exit 0
|
|

08-27-10, 10:03
|
|
Registered User
|
|
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,413
|
|
Recursive?
Quote:
Originally Posted by script
Please Try below:-
dir1="D:\Program Files\archive"
for Dir in "$dir1"
do
cd "$Dir"
echo `pwd`
find `pwd` -mtime +1 -type f -print
done
exit 0
|
You do NOT need the for loop, the find command will recourse the directory tree including it's sub-directories.

__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
|
|

08-31-10, 03:08
|
|
Registered User
|
|
Join Date: Aug 2010
Posts: 5
|
|
hi lkbrwn,,,
i used ur script, please see LOGS below
+ dir1=Program Files/archive
+ cd D:
+ find 'Program Files/archive' -mtime +60 -type f
File not found - -MTIME
File not found - +60
File not found - -TYPE
File not found - F
+ exit 0
it seemed like it's using the find of command prompt as i've read its syntax
hi script and lkbrwn,,
it's ok to use for loop because i'm actually creating the scrip for multiple directory,, i just first tried to one...
hi script,,
i used ur scrip, the error was "find: invalid switch"
|
|

08-31-10, 09:55
|
|
Registered User
|
|
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,413
|
|
Wrong, very wrong.
Quote:
Originally Posted by maxtodoscripts
hi lkbrwn,,,
i used ur script, please see LOGS below
+ dir1=Program Files/archive
+ cd D:
+ find 'Program Files/archive' -mtime +60 -type f
File not found - -MTIME
File not found - +60
File not found - -TYPE
File not found - F
+ exit 0
it seemed like it's using the find of command prompt as i've read its syntax
hi script and lkbrwn,,
it's ok to use for loop because i'm actually creating the scrip for multiple directory,, i just first tried to one...
hi script,,
i used ur scrip, the error was "find: invalid switch"
|
You are doing something WRONG, both my script and script's script work.
Are you using cygwin to execute? and are you saving the script in "Unix" format?
Show us your script.

PS: And it is NOT ok to loop because the find command already recourses the sub-directories.

__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|