Perl find command tweak


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl find command tweak
# 1  
Old 07-18-2016
Perl find command tweak

i use the following command to find files that were recently updated within the last hour:

Code:
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 that may be under mydata.

how can i make it search only in the /var/app/mydata directory and not any directory that may be under it?
# 2  
Old 07-18-2016
Try this:

Code:
perl -MFile::Find -le' find { wanted => sub { ! /^\.\z/s and $File::Find::prune = 1 and -f and 3600 / 86400 >= -M and print $File::Find::name; } }, shift' /var/app/mydata/

This User Gave Thanks to Chubler_XL For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Tar.gz help - Need to tweak

Hi Guys - I need help tweaking my tar.gz process. Currently, I compress all files in a directory, in which the parent directory is included in that. I only want to compress the "*.txt" files in the follow process: tar -zcvf ${_ESSB_TAR_PATH}/Essbase_Exports_${_DATETIMESTAMP}.tar.gz -C /... (3 Replies)
Discussion started by: SIMMS7400
3 Replies

2. Shell Programming and Scripting

perl line needing a tweak

Hi Folks, I have a perl line that looks like this and it works fine as is, but I need it to expand a bid further. perl -aF, -ne 'printf "conf zone %2\$s delete host %s,,,$F\n",split/\./,$F,2 if /^hostrecord/ &&/\b10\.8\.(|1)\.\d/' hosts.csv this code the way it is does this 10.8.3.0... (10 Replies)
Discussion started by: richsark
10 Replies

3. Shell Programming and Scripting

SED script needs tweak

I have a SED script that has worked for years, but broke today due to a new variable in a remote file. This is the part of the script that now won't work: sed "s|/directory/overview.gif|/directory/img/overview2.gif|g" | \ The path /directory/overview.gif is no longer static as it had been... (2 Replies)
Discussion started by: dockline
2 Replies

4. 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

5. Shell Programming and Scripting

How to tweak up

I have a script like this: while read abbrev; do sed 's/'$(echo "$abbrev" | tr "" "")'/'"$abbrev"'/g' 'output_rgt.'$$ >'tmp.'$$ mv 'tmp.'$$ 'output_rgt.'$$ done<'dict.shortcuts.'$$ And I don't know how to leave "mv" out. ('dict.shortcuts.'$$ may be... (14 Replies)
Discussion started by: MartyIX
14 Replies

6. 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

7. Shell Programming and Scripting

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 (4 Replies)
Discussion started by: MKNENI
4 Replies

8. 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