Hi,
I am confused about the output of find command.
Please see the two find commands below.
When i put "*.c" i get lots of files. But when i put *c only i get only one file.
Any answer??
$ find . -name "*c"
./clarify/cheval/hp_server/rulemanager/rulemansvc... (3 Replies)
when I do the find command from / , there are a lot of directories that I do not have access to and so I get
"find: cannot open ..."
How can I suppress these messages so only what was found is output.
I was thinking on
find / -name 'searchterm' | grep -v find
but this doesnt work
... (5 Replies)
I'm trying to autogenerate a PATH variable from the output of a find command as follows:
PATH=`find $dir -name "*.jar" | sed 's/$/:/'`
The output looks similar like this if I echo it:
PATH=/path/to/1.jar:
/path/to/2.jar:
/path/to/3.jar:
I want the path to be on one line.
I'm on... (3 Replies)
I'm using the below command to list files older than 2 hours but it returns redundant output, am I missing something.
# find . -mmin +120 -exec ls -l {} \;
total 0
-rw-r--r-- 1 root system 0 Oct 13 09:52 test1
-rw-r--r-- 1 root system 0 Oct 13 09:52 test2
-rw-r--r-- 1 root ... (5 Replies)
Hi,
I am triying to make sure that there exists only one file with the pattern abc* in path /path/. This directory is having many huge files. If there is only one file then I have to take its complete name only to use furter in my script.
I am planning to do like this:
if ; then... (2 Replies)
Hi guys -
I am trying a small script to tell me if there is a file that exists less than 1k. It should report ERROR, otherwise the check is good.
I wrote this script down, however it never runs in the if/then statement. It always returns the echo ERROR.
MYSIZE=$(find /home/student/dir1... (8 Replies)
Hi,
I'd like to assign the output of the find command to a variable.
What I need is to run the find command, and if it returns zero files, the program exits.
so i'm trying to assign the output of the find command to the $var1 variable....and then if this is less than one, I echo a... (2 Replies)
Hi All,
I am trying to run find command in a script to list out certain files based on a patter. However, when there is no file in the output, the script should exit.
Tried a couple of operators (-n, -z) etc but the script does not work.
I am confused whether a null string is returned... (3 Replies)
Please if You can help me debug why nothing is found by this command?
# echo "Zeus Robot" >> /home/vps/190/test
# cat /home/vps/190/test
Zeus Robot
# find /home/vps -type f -mtime 2 -size -1000k -exec grep -l "Zeus Robot" {} \; >> out
# cat out
# cat /home/vps/190/test
Zeus Robot
Why... (6 Replies)
Hi,
i have sh program which search for a file in a folder structure and provides its path. This is just used to see if that file exits more that once anywhere down the folder structure. I have used find command to search & printing it output on terminal.
I have attached screen shot of it.... (10 Replies)
Discussion started by: praveenkumar198
10 Replies
LEARN ABOUT DEBIAN
file::find::wanted
Wanted(3pm) User Contributed Perl Documentation Wanted(3pm)NAME
File::Find::Wanted - More obvious wrapper around File::Find
VERSION
Version 1.00
SYNOPSIS
File::Find is a great module, except that it doesn't actually find anything. Its "find()" function walks a directory tree and calls a
callback function. Unfortunately, the callback function is deceptively called "wanted", which implies that it should return a boolean
saying whether you want the file. That's not how it works.
Most of the time you call "find()", you just want to build a list of files. There are other modules that do this for you, most notably
Richard Clamp's great File::Find::Rule, but in many cases, it's overkill, and you need to learn a new syntax.
With the "find_wanted" function, you supply a callback sub and a list of starting directories, but the sub actually should return a boolean
saying whether you want the file in your list or not.
To get a list of all files ending in .jpg:
my @files = find_wanted( sub { -f && /.jpg$/ }, $dir );
For a list of all directories that are not CVS or .svn:
my @files = find_wanted( sub { -d && !/^(CVS|.svn)$/ }, $dir ) );
It's easy, direct, and simple.
WHY DO THIS ?
The cynical may say "that's just the same as doing this":
my @files;
find( sub { push @files, $File::Find::name if -f && /.jpg$/ }, $dir );
Sure it is, but File::Find::Wanted makes it more obvious, and saves a line of code. That's worth it to me. I'd like it if find_wanted()
made its way into the File::Find distro, but for now, this will do.
FUNCTIONS
find_wanted( &wanted, @directories )
Descends through @directories, calling the wanted function as it finds each file. The function returns a list of all the files and
directories for which the wanted function returned a true value.
This is just a wrapper around "File::Find::find()". See File::Find for details on how to modify its behavior.
COPYRIGHT & LICENSE
Copyright 2005-2012 Andy Lester.
This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License v2.0.
perl v5.14.2 2012-06-08 Wanted(3pm)