Perl Script Error with find command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl Script Error with find command
# 1  
Old 03-26-2008
Data Perl Script Error with find command

Guys,

I need to find all the files ending with either dmp or dmp.Z. This command is giving me error.

@files =`find $path \(-name "*.dmp" -o -name "*.dmp.Z"\) -mtime +30`;

sh: 0403-057 Syntax error at line 1 : `(' is not expected.

Thanks in advance
# 2  
Old 03-26-2008
You need to double the backslashes in order for them to be passed through to the shell. Backticks in Perl undergo "double-quotish" substitution so one level of backslashes gets eaten by Perl, basically.
# 3  
Old 03-26-2008
Thanks era,

You mean like this.
@files =`find $path \\(-name "*.dmp" -o -name "*.dmp.Z"\\) -mtime +30`;

This is not working either.
# 4  
Old 03-26-2008
If you copy+pasted that verbatim then the error message "find: invalid predicate `(-name'" should be self-explanatory -- you need a space in between there. Also before the closing paren.
# 5  
Old 03-26-2008
MySQL

Smilie

cool. It is working now.

@files =`find $path \\( -name "*.dmp" -o -name "*.dmp.Z" \\) -mtime +30`;

Thanks a lot era.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl find command tweak

i use the following command to find files that were recently updated within the last hour: perl -MFile::Find -le' find { wanted => sub { -f and 3600 / 86400 >= -M and print $File::Find::name; } }, shift' /var/app/mydata/ this command works well. however, it seems to also search directories... (1 Reply)
Discussion started by: SkySmart
1 Replies

2. Shell Programming and Scripting

Perl script to find last column

Dear all, I am new bee in perl scripting,i have generated one report in which i want to paste some data/text at the end,plz help me format is like this $worksheet1->write( 'A5',,$format2); i want to paste my text after this column A50 in column A51 but this column is variable it may... (1 Reply)
Discussion started by: sagar_1986
1 Replies

3. UNIX for Dummies Questions & Answers

Perl Script:how to find how many parameters are required to run the script

How to find how many parameters are required to run a Perl script? (1 Reply)
Discussion started by: Lakshman_Gupta
1 Replies

4. Shell Programming and Scripting

perl/unix: script in command line works but not in perl

so in unix this command works works and shows me a list of directories find . -name \*.xls -exec dirname {} \; | sort -u | > list.txt but when i try running a perl script to run this command my $query = 'find . -name \*.xls -exec dirname {} \; | sort -u | > list.txt';... (2 Replies)
Discussion started by: kpddong
2 Replies

5. Shell Programming and Scripting

Perl-OS command to find out what kind

I need to know a command to find out which version of Perl Im currently running. Thanks Ben (2 Replies)
Discussion started by: bigben1220
2 Replies

6. Shell Programming and Scripting

Find Command in the script throw error

Hi I have script that is developed to serch for 30 days old Directory & Files and then remove them ... when i run it successfully removes the Directory & files & but it throw errors on the screen .. .. + find . -type f -mtime +30 -exec rm -f {} ; + exit please help me ?? I... (0 Replies)
Discussion started by: Beginner123
0 Replies

7. Shell Programming and Scripting

Error executing shell command from a perl script

Hi Gurus, I've a find command that gets the list of files from a source directory where the extension is not html, xml, jsp, shtml or htaccess. The below find command runs fine from the command prompt or in a shell script. I need to eventually run it in a PERL script and am getting the... (5 Replies)
Discussion started by: voorkey
5 Replies

8. Shell Programming and Scripting

[Perl] Accessing array elements within a sed command in Perl script

I am trying to use a script to replace the header of each file, whose filename are stored within the array $test, using the sed command within a Perl script as follows: $count = 0; while ( $count < $#test ) { `sed -e 's/BIOGRF 321/BIOGRF 332/g' ${test} > 0`; `cat 0 >... (2 Replies)
Discussion started by: userix
2 Replies

9. UNIX for Dummies Questions & Answers

how to use sed or perl command to find and replace a directory in a file

how to use sed command to find and replace a directory i have a file.. which contains lot of paths ... for eg.. file contains.. /usr/kk/rr/12345/1 /usr/kk/rr/12345/2 /usr/kk/rr/12345/3 /usr/kk/rr/12345/4 /usr/kk/rr/12345/5 /usr/kk/rr/12345/6 /usr/kk/rr/12345/7... (1 Reply)
Discussion started by: wip_vasikaran
1 Replies

10. Shell Programming and Scripting

using the perl version of the find command...

hi, i am looking through the perl documentation in the man pages for the first time but I have looked at some other reference giudes before (at a glance) and remember that there is a find command used by perl can any one give me a structured example of that command and how it works and if possible... (2 Replies)
Discussion started by: moxxx68
2 Replies
Login or Register to Ask a Question