Questions tagged [find]

search for files in a directory hierarchy

Find is used to look files in a directory hierarchy. You can refer to its manpage here.

Examples:

Look for all files on a server owned by user siegfried:

 find / -user siegfried

Find all files ending in php en remove them:

 find / *.php -exec rm '{}' \;
315 questions
124
votes
8 answers

Can I make `find` return non-0 when no matching files are found?

Even when /tmp has no file called something, searching for it with find will return 0: $ find /tmp -name something $ echo $? 0 How can I get a non-zero exit status when find does not find anything?
yael
  • 1,439
7
votes
2 answers

List directories not containing a file

I've seen similar questions to this, but nothing I can find related directly to files. Is there any way to give me a list of directories which do not contain a specific…
Stefhen
  • 143
4
votes
1 answer

Linux command to find all *.rb files

I still can't figure out how to use the Linux find command. I'm trying to find all the .rb files under the /var/www directory. What's the correct command to type in Bash?
learningtech
  • 7,445
  • 23
  • 64
  • 88
2
votes
4 answers

find executables

The following command works on Ubuntu (GNU findutils 4.4.2) but not on Fedora (4.2.27) time find . -maxdepth 1 -type f -executable -print How do I find executable files using older version of find?
shantanuo
  • 3,619
2
votes
2 answers

Unable to change the font in bold to yellow font in Less

Problem: to change the bolding which affects the word "expression" to the color yellow in Less: alt text http://files.getdropbox.com/u/175564/man-bolding-highlight.png My commands which affects Less export LESS_TERMCAP_mb=$'\E[01;31m' # begin…
1
vote
1 answer

How can I make find return non-0 if -exec command fails?

When I run the find command with an -exec subcommand that fails, find returns a 0 exit code: $ find . -iname '*.txt' -exec ls foo \; ls: foo: No such file or directory ls: foo: No such file or directory ls: foo: No such file or directory ls: foo: No…
David Eyk
  • 667
  • 1
  • 7
  • 18
1
vote
1 answer

find command + print manipulation

with the following command: find /tmp -depth -name file I get the: /tmp/file /tmp/test_file/file But what I need to add to find command in order to get the following print? file=/tmp/file file=/tmp/test_file/file
klod
  • 195
1
vote
4 answers

Unable to find a file by content

The file contains the following line google.friendconnect I got the line from the following command cat * | grep google However, I do not know its location. How can you get the precise location of the file without Ack?
0
votes
4 answers

Linux Find to delete files in folders

the goal is to find directories with given name and delete all files inside them, keeping actual directories find /home/www/sites/ -iname '_cache' -exec du -hs {} \; this gives me a list of files with their size 204K …
0
votes
2 answers

find files without any extension

How do I find the files those do not have an extension? For e.g. in the following screen, I will like to return the file sconnect and not .xls -rwxr-xr-x 1 root root 12K Mar 7 19:29 ./Purchase_ORDER.xls -rwxr-xr-x 1 root root 176 Mar 7 19:29…
shantanuo
  • 3,619
0
votes
3 answers

can not find a directory with find command

I tried using the command sudo find / -type d -iname firefox It gave me the following output /usr/share/doc/firefox /usr/lib/firefox /home/ashu/.mozilla/firefox /etc/firefox But i have a directory named firefox located at…
0
votes
2 answers

Looping in a directory to find a folder and delete

I use Dreamweaver to upload the web page to my site, it bring a folder called _note to everywhere in my site. I would like to ask how can I loop in the directory(/home/user/htdocs) to find the folder _note and delete it?
0
votes
2 answers

rename files and dirs under linux

why the following command " find / -name 'node1' -print0 | xargs -0 rename 's/node1/node_STAR/' " not replace the node1 under /var/tmp directory? my target is to scan linux sys and rename directories and files example from my linux…
yael
  • 1,439
0
votes
0 answers

Finding files that does not have a particular owner OR group

I'd like to use GNU find to find sub-directories and files under the current path that either does not have the particular user OR the particular group. find . -not -user USERXXX -or -not -group GROUPYYY seems not working. I can tell that because…
Computist
  • 473
0
votes
0 answers

Copy User and Group Ids for all files of a directory tree

I am looking for a way to copy uids and gids for all files of a directory tree from one machine to another. The directory tree is believed to be identical on both machines except that uids and gids got corrupted on the target machine. The background…
1
2