Questions tagged [find]
search for files in a directory hierarchy
315
questions
0
votes
2
answers
14k
views
Linux Find and Zip Files
I'm running into 2 problems when working with my logs and the find command.
I am having problems with the mtime option. The 1st command below shows me a few files from March 5th till March 7th, like ...
2
votes
1
answer
310
views
RSYNC Slow / Copy only changed files?
I have a server that maintains thousands of log files that are nested in thousands of directories. At the moment, I am using RSYNC to copy those log files to a web server where I parse them and make ...
1
vote
1
answer
323
views
find ... -exec command not executing on all files found
How come this command:
find . -name \*.css -o -name \*.php -type f
gives me a list of all the *.css and *.php files BUT adding the 'exec' option:
find . -name \*.css -o -name \*.php -type f -exec ...
3
votes
3
answers
1k
views
find and remove duplicates filenames in directory hierarchy
#!/bin/sh
LASTBASE=""
find $1 -type f -print | rev | sort | rev | while read FILE
do
BASE=$(basename "$FILE")
if [ "$BASE" = "$LASTBASE" ]; then
rm "$FILE"
LASTBASE="$BASE"
done
2
votes
2
answers
3k
views
centos - how to find a filename with all the possible extensions?
I need to perform a search for "foo" and return all the filenames/directories with this name (e.g. foo.php, foo.txt etc). It should run through the whole filesystem and find even hidden files.
I've ...
2
votes
3
answers
3k
views
Running a script containing find with a regexp fails in cron but works in a shell
I have the following script in my /etc/cron.d:
19 15 * * * root /opt/scripts/clean-nexus-release-repo.sh
The clean-nexus-release-repo.sh script looks like this:
#!/bin/bash
find /opt/sonatype-work/...
2
votes
2
answers
399
views
-links option in find command
Please explain me what is use of -links option in find command. The man page is not giving much information. Some of our scripts we are using have an option -links 0 in find command.
I am using the ...
6
votes
6
answers
6k
views
Get Size of All Folders in Directory
I want to get the size of all directories within a specific directory. I was thinking something like
find . -type d -exec du -sh {} \;
But that returns all directories recursively. How can I limit ...
1
vote
2
answers
7k
views
How to find any file that is an executable or library
Let's say someone provides you with a tarball, saying it is source code and nothing else. You want to make sure that is true, and that no virus-laden executables or libraries are tucked away in a ...
2
votes
1
answer
434
views
finding files that match a precise size: a multiple of 4096 bytes [duplicate]
I have several drupal sites running on my local machine with WAMP installed (apache 2.2.17, php 5.3.4, and mysql 5.1.53). Whenever I try to visit the administrative page, the php process seems to die....
1
vote
2
answers
322
views
How to use `list` to locate attributes changed to `s---ia-------`?
My linux CentOS server has been compromised lately (rootkit). Some files attributes have been changed, for example the command :
lsattr /bin/ls
gives
s---ia------- /bin/ls
How cand I use find ...
1
vote
2
answers
117
views
Using find to locate files modified in Aug
I need to find files modified in August. Here's my portion of the command that narrows down the modification time. This works, but it seems to be missing some files. I'm guessing this is missing ...
1
vote
3
answers
146
views
Linux single find command within thousands of directories [closed]
I have to search through about 7,000 directories and determine the number of PDFs modified last month grouped by the type of PDF, which is in a MySQL database. The folder structure is...
/folder/to/...
0
votes
1
answer
271
views
finding directories that consume a lot of the AFS volume quota
The AFS volume quota is almost exceeded for one of our computer users. Running fs listquota or fs lq gives him a warning:
olifri@ubuntu:~$ fs listquota ~
Volume Name Quota ...
0
votes
4
answers
136
views
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 ...
17
votes
6
answers
58k
views
How can I use netsh to find a rule using a pattern
I'm wondering whether anyone in Microsoft has ever come to a situation where they can't remember a rule's name!
The netsh advfirewall firewall show rule only accepts 1 name and no pattern matching ...
0
votes
4
answers
907
views
is there an 'upwards' find?
To find files starting from a certain path, I can use find <path> .... If I want to find 'upwards', i.e. in the parent directory, and it's parent, and..., is there an equivalent tool?
Intended ...
4
votes
1
answer
374
views
Glob Not Match?
How to list files that don't match a glob?
E.g., let's say I have a directory that contains hundreds of files, 97% of which have the filename extension .png.
I know I can list the PNG files with:
...
0
votes
4
answers
645
views
Calculate disk space occupied by many .png files
I have 357 .png files located in different sub dirs of the current dir:
settings# find . -name \*.png |wc -l
357
settings# find . -name \*.png | head
./assets/authenticationIcons/audio.png
./...
5
votes
4
answers
6k
views
How to do a for loop of filenames with spaces using find
I have the following script - its supposed to loop files names using find but it seams to break the files names up by a space? I need the file names to remain intact
#!/bin/bash
for file in `find -...
5
votes
2
answers
326
views
Does "find" open files?
I recently issued this command:
find . -type f | wc -l
To count how many files are in my public_html folder.
Shortly after, Nginx returned 500 internal server error and error.log was being flooded ...
2
votes
3
answers
14k
views
find count of images within a directory
I wanted to find the number of image files within a directory. I ended up using this :
find . -type f -exec file {} \; | grep -c -i 'image'
This feels like an inefficient way of doing it. I could ...
1
vote
2
answers
159
views
linux or solaris match files with uniq syntax
how to match all files that start with the string OS_PATCH
and ended with .gz
remark - the solution must to fit Linux and Solaris OS
this task could be by find command or maybe with ls with ...
9
votes
5
answers
15k
views
How to find all filenames with given extension
I need to find all .pem files on my system. Would the following do this?
sudo find / -type f -name *.pem
If not, how would I write a find command to find every file of the sort?
2
votes
2
answers
76
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
2
answers
73
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
4
answers
226
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?
2
votes
3
answers
4k
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
2
answers
3k
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
4
answers
146
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 ...
6
votes
4
answers
5k
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
1
answer
2k
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
1
answer
991
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
1
answer
154
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 ...
28
votes
3
answers
25k
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 ls,...
4
votes
2
answers
7k
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
3
answers
107
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
3
answers
6k
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
1
answer
839
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 ...
49
votes
8
answers
112k
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
4
answers
1k
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 ...
1
vote
3
answers
20k
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 ...
1
vote
5
answers
974
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 ...
11
votes
5
answers
27k
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 . -...
33
votes
8
answers
23k
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 ...
8
votes
1
answer
19k
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
1
answer
3k
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
3
answers
303
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
1
answer
389
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
2
answers
125
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 ...