search for files in a directory hierarchy

learn more… | top users | synonyms

2
votes
2answers
61 views

How do I detect the version of find on OSX

I need to detect which version of the find command is used from a shell script. GNU find supports the --version argument but the find command on OSX apparently does not support that. Is there a way to ...
0
votes
2answers
56 views

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 ...
2
votes
4answers
211 views

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? ...
1
vote
3answers
2k views

On linux how can make a list of files that are owned by a particular owner and then fix the group and owner?

I have a deep and complex file system where some files have been accidently written by root. I want to change the ownership of those files back to the original owner in one go. I am playing with ...
0
votes
2answers
2k views

finding files on linux in non hidden directory

In the following command i want to search only only the directories which are non hidden how can i do this using the following command .Iwant to ignore hidden directories while searching the log file ...
3
votes
4answers
127 views

`find` command not available in web host, how to implement a delete based on modification time using other commands?

I'm creating a simple datebase backup solution for a client using web hosting at DataFlame. The web hosting account provides access to cron but not a shell. I have a database backup script creating ...
5
votes
4answers
3k views

How to tell if a file is older than 30 minutes on AIX?

I'd like to write a shell script in ksh or bash which exits with 1 if a specific file is older than 30 minutes. (Last modification time is older than half hour). It would be easy on a Linux or a ...
-2
votes
1answer
443 views

On Unix on could I get a listing of all mp3 files inside a directory containing other directories with their full path?

Someone said to me use the find command but I'm not exactly sure how to do it. Basically I need this: suppose I have a folder called dir1 and it contains three sub-directories (dir2, dir3 and dir4 ...
0
votes
1answer
546 views

rsync files created or modified from windows share on cifs mount

I want to rsync the files to my local linux box, but I only want files that have been created or modified within the past 30 days. I'm mounting a windows share from linux using this command: mount ...
2
votes
1answer
138 views

Recursively search and replace the contents of multiple file types

I have thousands of web files(*.php, *.htm, *.html, etc) that contain an absolute path(http://site.com/sites/etc). I need to scan a directory and all subdirectories for the various file types and ...
9
votes
2answers
4k views

FreeBSD: How to know real file size on zfs with compression on?

I'm using zfs on my FreeBSD 9.0 x64 and pretty happy with it, but I find it hard to count directory real, not compressed, size. Surely I can walk over the directory and count every file size with ...
3
votes
2answers
2k views

how to list files that are NOT open using find command

I want to "list" all the files that are NOT open, within a certain directory using the GNU find command. Now, I am able to list the files that are open, but can't figure out a way to do the inverse of ...
0
votes
3answers
93 views

Find everything installed since server creation

I often seem to be dealing with "almost virgin" Linux installations: VMs that were created for a purpose, used briefly, but after a while we're not sure exactly what's on it. What I'd like to be able ...
1
vote
2answers
4k views

How can I recursively delete old files and prune resulting empty directories?

We're using an AIX server to house thousands and thousands of little files in a nested directory structure. I'm trying to write a script that will recursively delete old files, and then delete the ...
3
votes
1answer
218 views

How to find any symbolic links that point outside a given folder tree?

I have a bunch of folders/files that are 10+ levels deep. How can I find any symbolic links that point outside this folder tree? I tried find -type l but this returns all soft links... even ...
4
votes
7answers
16k views

Remove path from find command output

I have a bash script for deploying code from a beta environment to a production environment but currently I have to add the list of files to a txt file manaully and sometime I miss some. Basically my ...
2
votes
4answers
987 views

Delete old files in large folder

I have a folder which contains many files. I want to delete files older than 30 days, so I use the command: find cache/ -mtime +30 -exec rm {} \; But my SSH session disconnects before the command ...
2
votes
3answers
6k views

how find datacenter using a ip address related to that datacenter? [closed]

I have a vds and it's really good! I have some problems with my reseller of that server because of their support. I want to buy a server from that datacenter directly. How can I find that datacenter ...
0
votes
5answers
570 views

find command + exe status diff from 0 when file not found

how to enable find command to print exe status diff from 0 when find command not find the file? according to my example when I try to find the test1.txt file , $? set to 0 but I expect to get value ...
4
votes
5answers
8k views

What is the correct find -exec syntax

I wanted to delete files that were greater than 2MB within a specific folder. So I ran: find . -size +2M And I got a list of two files ./a/b/c/file1 ./a/f/g/file2 So I then run: find . ...
9
votes
5answers
5k views

Linux find command - show progress

I was wondering if there's any way to display some kind of progress info when searching for files in linux using find. I often find myself searching for files on a big disk and some kind of progress ...
5
votes
1answer
8k views

Find, and sort results by date created

How can I sort the results of find? I want to sort by date created asc? find /docs -type f | sort Sorts by filename not date created. Thanks.
0
votes
1answer
483 views

Issue with rsync -R wrapped in a find command

I'm trying to copy all the files named 'specials.xml' in the current and all subdirs, and also create the name of each sub-directory. I'm using -R to rsync so it creates the relative paths for each ...
2
votes
3answers
261 views

How do I find this string?

I'm trying to match these file names with the find command: 4702011-10-21CR719557-R85262-ALPHA.jar 4702011-10-21CR719557-R85262-BETA.jar I'm reasonable familiar with Java-Perl regex syntax. ...
0
votes
1answer
280 views

Reverse and modify copy file to all subfolders command, xargs

i found this online it copy file to every sub folder on the current dir for full tree depth find -maxdepth 1 -type d -print0 | xargs -0 -n1 cp -v .htaccess now would be nice if it could ask if ...
1
vote
2answers
79 views

Can find show directories with contained directories' time stamps?

I have a script to clean out old files and directories in a log area like: find . -mtime +${NUM_DAYS} -type d -exec rm -rf '{}' \; However if I run this 2 levels up from the files that have changed ...
3
votes
4answers
5k views

Find the location of libmysqlclient.so.X file in Linux environments

I'm putting together a script that has a requirement of knowing libmysqlclient.so.[15|16|18] .so file. It's usually located in /usr/lib/ , /usr/lib64/ or a mysql/ subdirectory of the aforementioned ...
1
vote
3answers
3k views

How do I search by multiple keywords when using awk or grep?

I have a collection of files. I want to search through them all with grep to find all and only those which contain anywhere within them both the strings keyword1 and keyword2. I would also like to ...
21
votes
4answers
15k views

Bash find command verbose output

Good time of the day, Is there way to tell the bash "find" command to output what it is doing (verbose mode) ? For example for the command: find /media/1Tb/videos -maxdepth 1 -type d -mtime +7 -exec ...
4
votes
2answers
642 views

find all directories having less than x files inside

Assume starting at some directory in the filesystem. This base directory has lots of subdirectories (not nested!). Each of the subdirectories has an arbitrary number of files withing. How can I find ...
0
votes
5answers
243 views

search files based on text file containing list of files

I have a text file containing file names only (it does not contain their paths). I need to find these files which may lie in any of the subfolders and then copy or move them to other location. To find ...
2
votes
1answer
296 views

Find and delete all but N largest files in 100s of directories

I have 100s of sibling directories on a BSD/Unix system, each with a collection of files in it. I'd like to delete all but the N largest files in each directory. (N is 5 for me.) Assuming that I can ...
2
votes
2answers
1k views

How to use sed, perl to rename files and its contents with a particular pattern in a given directory?

Given a directory "Centos1" which has few files named Centos1.x, Centos1.y, Centos1.z and these files also has "Centos1" in their contents. Using a single command ( using find, sed, perl -pie ) how ...
1
vote
2answers
720 views

How to find .h,.c and .cc files under current directory in linux?

find . -name "*.[hc]|*.cc" The above doesn't work,why? UPDATE How do I find these 3 kinds of files with a single pattern?
0
votes
2answers
70 views

Running expand on a set of files

I'm trying to run the expand shell command on all files found by a find command. I've tried -exec and xargs but both failed. Can anyone explain me why? I'm on a mac for the record. find . -name ...
1
vote
2answers
816 views

find files and search for within tail

The following is working as expected. find /opt/ -name "somefile.out" -exec grep 'Connection refused' {} \; | more But if I want to search only in the tail of the found files, I can not add tail or ...
0
votes
3answers
48 views

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 ...
1
vote
1answer
304 views

Using Find, Grep, Awk, or Sed To Rename Server After Cloning

My client tells me they have cloned a VM in VMWare of an Ubuntu Linux server. Now it's my job to get into all the files and find out what still has the old server name of "bishop" and change it to ...
1
vote
1answer
305 views

MySQL can't write to tmp folder, how do I find this tmp folder

MySQL (using MAMP) says it can't write to Can't create/write to file '/private/var/folders/AO/AOyal7b0GU844L1VJDb3Bk+++TI/-Tmp-/#sqld035_6_0.MYI But using finder I can't find this location. How can I ...
0
votes
2answers
480 views

find command to find php files but exclude a certain directory

How do I run a find command to find php files but I exclude a folder i.e. /usr/local/bin?
1
vote
3answers
5k views

How do I find all files of a specific type in RHEL on the command line?

I am looking for files of type .flv, .avi, etc I would like to see a list of all the files (on my server) of those file types (I don't mind doing it one by one, i.e. seeing all the files of .flv, ...
7
votes
3answers
4k views

Non-recursive find on linux

I am trying to find all directories that are directly inside the current directory and older than a specific age. The trick is, I only want to consider the age of the immediate descendants of the ...
0
votes
2answers
68 views

How to find mail on shared linux hosting and delete after forwarding

I'm forwarding mail from a shared hosting account to a gmail address. The mail forwarder does not delete the mail after forwarding so the directory is getting full. I tried the following in a cron ...
18
votes
3answers
9k views

How can I handle spaces in file names when using xargs on find results?

One of my common practices is to perform greps on all files of a certain type, e.g., find all the HTML files that have the word "rumpus" in them. To do it, I use find /path/to -name "*.html" | xargs ...
7
votes
1answer
7k views

How do I find circular symbolic links?

I'm working on a HP-UX system and I want to find if there are any circular symbolic links. So far I'm using the command: ls -lrt `find ./ -follow -type l` But it's only doing ls -lrt on current ...
0
votes
1answer
594 views

How does find command sort results?

I have an old messy shell script. One of the steps executes find command with some parameters and expects the results to be sorted by creation time. It works well on old machines (find version is ...
2
votes
4answers
1k views

How to bulk rename files to remove an extraneous space from before the extension

I have a bunch of files who's filename follows the pattern 'filename.ext'. eg: filename .ext I would like to rename all of these to remove the space before the .ext. eg: filename.ext I can find ...
2
votes
1answer
835 views

How to find files with trailing slash in linux

I have some files in the filesystem that end with a trailing slash like so: my_text_file_1.txt\ some_other_file_2.pl\ I usually use find for these cases, but the following did not work: find . ...
1
vote
5answers
992 views

How to restrict Linux find by prefix?

I have a directory A with a large number of sub directories and files and want to get a list of all files named foo that are inside of a directory in A that matches *bar. E.g.: Yes: ...
0
votes
2answers
117 views

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