Sponsored Content
Top Forums Shell Programming and Scripting How to restrict Find only search the current directory? Post 302772683 by littlewenwen on Tuesday 26th of February 2013 12:55:04 PM
Old 02-26-2013
How to restrict Find only search the current directory?

hello, all

I have googled internet, read the man page of Find, searched this forum, but still could not figure out how.

My current directory is:

Code:
little@wenwen:~$ pwd
/home/little
little@wenwen:~$

I want to use find command to list the files in my current directory, how should i write the find command? thank you very much.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

find directory not including current

Using Solaris 8, I've forgotten how to exclude the current directory in the find results. find . -type d ! -name "*.CAP" I want every directory that does not match the *.CAP pattern, except the current directory. (2 Replies)
Discussion started by: dangral
2 Replies

2. UNIX for Dummies Questions & Answers

Question about Restricting Search path of FIND to current directory

Hi, By default FIND command searches for matching files in all the subdirectories within the specified path. Is there a way to restrict FIND command's search path to only the specified directory and NOT TO scan its subdirectories. Any help would be more than appreciated. Thanks and Regards (2 Replies)
Discussion started by: super_duper_guy
2 Replies

3. Shell Programming and Scripting

how do i exclude the current directory when using find?

i want to compile a list of files in all sub directories but exclude the current directory. the closest i could get was to search 'only' the current directory, which is the opposite of what i wanted. find . ! -name . -prune (7 Replies)
Discussion started by: mjays
7 Replies

4. UNIX for Dummies Questions & Answers

Restrict my search to current directory.

Hi every1, There is a folder with .lst files which has email id's of our project group. I want to find files which has my email id starting with sachin but i dont want find command to search subdirectories. I have read about prune but i didnt understand that. I am pretty new in this field.... (7 Replies)
Discussion started by: sachin.gangadha
7 Replies

5. Shell Programming and Scripting

non recursive search in the current directory only

Hi, Am trying for a script which should delete more than 15 days older files in my current directory.Am using the below piece of code: "find /tmp -type f -name "pattern" -mtime +15 -exec /usr/bin/ls -altr {} \;" "find /tmp -type f -name "pattern" -mtime +15 -exec /usr/bin/rm -f {} \;" ... (9 Replies)
Discussion started by: puppala
9 Replies

6. UNIX for Dummies Questions & Answers

find command to look for current directory only

i have this find command on my script as: for i in `find $vdir -name "$vfile" -mtime +$pday` the problem with this code is that the sub-directories are included on the search. how do i restrict the search to confine only on the current directory and ignore the sub-directories. please advise.... (7 Replies)
Discussion started by: wtolentino
7 Replies

7. UNIX for Dummies Questions & Answers

"-maxdepth 1" argument for Solaris find. Other way to restrict find in only one directory?

Hi I wish to find only files in dir /srv/container/content/imz06/. It means exclude subfolder /srv/container/content/imz06/archive/ > uname -a SunOS testbox6 5.10 Generic_139555-08 sun4v sparc SUNW,Sun-Blade-T6320Its Solaris default "find" > find /srv/container/content/imz06/* -name... (4 Replies)
Discussion started by: slashdotweenie
4 Replies

8. Homework & Coursework Questions

C Program to search and read all named pipes in current directory

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Write a C program to search the current directory for all pipes. 1. It will print the pipe... (2 Replies)
Discussion started by: natwickley
2 Replies

9. UNIX for Dummies Questions & Answers

Restricting a Find search to the current directory only

Hi All, I am trying to delete file (with a mtime older than 2 days) from the current directory ONLY using: find . -daystart -maxdepth 1 -mtime 2 -exec rm {} \; but this doesn't seem to work it is still find files in subdirectories which I don't want to delete. Please can anyone offer... (2 Replies)
Discussion started by: daveu7
2 Replies

10. Shell Programming and Scripting

Search: find current line, then search back

Hello. I want to find a line that has "new = 0" in it, then search back based on field $4 () in the current line, and find the first line that has field $4 and "last fetch" Grep or Awk preferred. Here is what the data looks like: 2013-12-12 12:10:30,117 TRACE last fetch: Thu Dec 12... (7 Replies)
Discussion started by: JimBurns
7 Replies
File::Find::Object(3pm) 				User Contributed Perl Documentation				   File::Find::Object(3pm)

NAME
File::Find::Object - An object oriented File::Find replacement SYNOPSIS
use File::Find::Object; my $tree = File::Find::Object->new({}, @targets); while (my $r = $tree->next()) { print $r ." "; } DESCRIPTION
File::Find::Object does same job as File::Find but works like an object and with an iterator. As File::Find is not object oriented, one cannot perform multiple searches in the same application. The second problem of File::Find is its file processing: after starting its main loop, one cannot easilly wait for another event and so get the next result. With File::Find::Object you can get the next file by calling the next() function, but setting a callback is still possible. FUNCTIONS
new my $ffo = File::Find::Object->new( { options }, @targets); Create a new File::Find::Object object. @targets is the list of directories or files which the object should explore. options depth Boolean - returns the directory content before the directory itself. nocrossfs Boolean - doesn't continue on filesystems different than the parent. followlink Boolean - follow symlinks when they point to a directory. You can safely set this option to true as File::Find::Object does not follow the link if it detects a loop. filter Function reference - should point to a function returning TRUE or FALSE. This function is called with the filename to filter, if the function return FALSE, the file is skipped. callback Function reference - should point to a function, which would be called each time a new file is returned. The function is called with the current filename as an argument. next Returns the next file found by the File::Find::Object. It returns undef once the scan is completed. item Returns the current filename found by the File::Find::Object object, i.e: the last value returned by next(). next_obj Like next() only returns the result as a convenient File::Find::Object::Result object. "$ff->next()" is equivalent to "$ff->next_obj()->path()". item_obj Like item() only returns the result as a convenient File::Find::Object::Result object. "$ff->item()" is equivalent to "$ff->item_obj()->path()". $ff->set_traverse_to([@children]) Sets the children to traverse to from the current node. Useful for pruning items to traverse. $ff->prune() Prunes the current directory. Equivalent to $ff->set_traverse_to([]). [@children] = $ff->get_traverse_to() Retrieves the children that will be traversed to. [@files] = $ff->get_current_node_files_list() Gets all the files that appear in the current directory. This value is constant for every node, and is useful to use as the basis of the argument for "set_traverse_to()". BUGS
No bugs are known, but it doesn't mean there aren't any. SEE ALSO
There's an article about this module in the Perl Advent Calendar of 2006: <http://perladvent.pm.org/2006/2/>. File::Find is the core module for traversing files in perl, which has several limitations. File::Next, File::Find::Iterator, File::Walker and the unmaintained File::FTS are alternatives to this module. LICENSE
Copyright (C) 2005, 2006 by Olivier Thauvin This package is free software; you can redistribute it and/or modify it under the following terms: 1. The GNU General Public License Version 2.0 - http://www.opensource.org/licenses/gpl-license.php 2. The Artistic License Version 2.0 - http://www.perlfoundation.org/legal/licenses/artistic-2_0.html 3. At your option - any later version of either or both of these licenses. perl v5.10.0 2009-06-18 File::Find::Object(3pm)
All times are GMT -4. The time now is 07:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy