10-17-2005
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
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi guys
I'm trying to move an empty directory to the $TRASH directory. Say the directory i have is ./hello/hello1/hello2 and i'm in hello2, and i want hello2 moved.
this code:
TRASH=$home/deleted
find "$TRASH/$1" -type d -exec rmdir { } \; 2>/dev/null
mv -f $1 $TRASH 2>/dev/null
works... (2 Replies)
Discussion started by: olimiles
2 Replies
2. UNIX for Dummies Questions & Answers
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
3. Shell Programming and Scripting
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
4. Shell Programming and Scripting
I am using the following command in a C shell script:
find . -name "*.*" -print | zip $ProjectZipFile -@
to zip files in a Unix (Sun and/or Linux) directory for archiving purposes. This command works fine, the only problem being that if sub-directories are present, they are included in... (5 Replies)
Discussion started by: phudgens
5 Replies
5. Shell Programming and Scripting
If I enter (simplified):
find . -printf "%p\n"
then all files in the output are prepended by a "." like
./local/share/test23.log
How can achieve that
a.) the leading "./" is omitted
and/or
b.) the full path to the current directory is inserted (enclosed by brackets and a blank)... (1 Reply)
Discussion started by: pstein
1 Replies
6. UNIX for Dummies Questions & Answers
In ubuntu, I want to update the title of the terminal window with the current directory path. Any ideas how this can be achieved?
---------- Post updated at 02:22 PM ---------- Previous update was at 02:08 PM ----------
Done it
---------- Post updated at 02:30 PM ---------- Previous update... (2 Replies)
Discussion started by: kristinu
2 Replies
7. UNIX for Dummies Questions & Answers
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
8. Shell Programming and Scripting
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:
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... (3 Replies)
Discussion started by: littlewenwen
3 Replies
9. UNIX for Dummies Questions & Answers
How to get the current directory Path in your prompt?
i am getting a $ mark only in my prompt?
Please help me with this (3 Replies)
Discussion started by: Abhishek0683
3 Replies
10. Shell Programming and Scripting
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
FIND(1) General Commands Manual FIND(1)
NAME
find - find files meeting a given condition
SYNOPSIS
find directory expression
EXAMPLES
find / -name a.out -print
# Print all a.out paths
find /usr/ast ! -newer f -ok rm {} ;
# Ask before removing
find /usr -size +20 -exec mv {} /big ;
# move files > 20 blks
find / -name a.out -o -name '*.o' -exec rm {};
# 2 conds
DESCRIPTION
Find descends the file tree starting at the given directory checking each file in that directory and its subdirectories against a predi-
cate. If the predicate is true, an action is taken. The predicates may be connected by -a (Boolean and), -o (Boolean or) and ! (Boolean
negation). Each predicate is true under the conditions specified below. The integer n may also be +n to mean any value greater than n, -n
to mean any value less than n, or just n for exactly n.
-name s true if current filename is s (include shell wild cards)
-size n true if file size is n blocks
-inum n true if the current file's i-node number is n
-mtime ntrue if modification time relative to today (in days) is n
-links ntrue if the number of links to the file is n
-newer ftrue if the file is newer than f
-perm n true if the file's permission bits = n (n is in octal)
-user u true if the uid = u (a numerical value, not a login name)
-group gtrue if the gid = g (a numerical value, not a group name)
-type x where x is bcdfug (block, char, dir, regular file, setuid, setgid)
-xdev do not cross devices to search mounted file systems
Following the expression can be one of the following, telling what to do when a file is found:
-print print the file name on standard output
-exec execute a MINIX command, {} stands for the file name
-ok prompts before executing the command
SEE ALSO
test(1), xargs(1).
FIND(1)