Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [find]

search for files in a directory hierarchy

0
votes
0answers
22 views

What is the option “-true” and “-false” of the “find” command used for? [duplicate]

man find describes the following command options: -false Always false. -true Always true. What are some cases in which this can be useful ?
0
votes
1answer
26 views

Update all Python files via Linux command

In my original Python files I have the following: from official.utils.flags import _base I need to change it to: from utils.flags import _base My file structure looks like this: . ├── README.md ├─...
0
votes
2answers
90 views

Windows search cannot find files in current directory

We have a windows server 2012 r2 that has the file server role and windows search installed. The drives with the shared folders are indexed and the shares folders are mapped on all clients. I can ...
0
votes
0answers
37 views

Find and cp whilst preserving modified date on files and folders

Morning all, I have this script that will find all files from the last 7 days and transfer them to a different location. I need it to maintain the modified date for the files and folder, currently ...
0
votes
1answer
9 views

find: equal file size limit but different unit returns different result

I noticed that the these two commands to list files below 5 GiB produce different results: find . -type f -size -5368709120c find . -type f -size -5G Specifically the one that uses kilobyte unit (...
0
votes
0answers
52 views

Linux - Find -exec command optimization

I have to copy a huge number of files that are stored in a directory structure that contains a huge number of nested subdirectories and files. I am interested in a specific type of files and I know ...
0
votes
1answer
30 views

access SpamAssassin SpamBox from command line

I am trying to create a CRONjob to delete spam older than x days. I can do this from the command line with non-spam emails by using the following script: find "/home/account/mail/example.com/username/...
1
vote
3answers
275 views

Solaris 11 find empty folders (-empty not work)

How to find empty dir and delete in Solaris 11. I try this: find . -type d -empty Output: find: bad option -empty find: [-H | -L] path-list predicate-list
0
votes
1answer
22 views

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 ...
3
votes
2answers
34 views

Can I reduce CPU usage on a large recursive find + chmod command?

I'm using the following command to perform permissions fixes: sudo find . -type f -exec chmod 470 {} \; There are many thousands of files to update the permissions on. It also spikes the CPU usage ...
1
vote
0answers
36 views

Cron job not deleting files in cifs mount

I have a cron job that runs a shell script. The contents of the shell script is as follows: #!/bin/bash cd sudo service confluence stop NOW=$(date +"%Y%m%d-%H%M%S") mkdir Backup/db mkdir Backup/...
1
vote
0answers
172 views

Find files created within a time frame with Linux find command

This command runs fine find /eqtynas/ -type f -mtime -1 -print0 | du -ch --files0-from=- --total -s > /tmp/24hourUsage.20171101 & however it takes in a 24 hour block of time since I run the ...
1
vote
1answer
736 views

Copy list of files (-I flag) with gsutil preserving path

I am trying to copy all pictures and static files to a bucket of mine in Google Cloud Platform. I am attempting this command from the root dir of my app: find -regextype posix-extended -iregex ".*\.(...
0
votes
1answer
26 views

How to filter files which have permissions changed in last n minutes

Example, I have two files -rw-rw---- 1 1000 1000 5 Sep 28 01:25 file1 -rw-rw---- 1 1000 1000 13 Sep 28 01:25 file2 After echo "asdfg" >> file1 (file1 content was modified) -rw-rw---- 1 ...
0
votes
1answer
301 views

Argument list too long with grep

Normally to search and replace a string in a selection of files, I would find with: grep -rl 'pattern' . This works fine unless you have a LOT of matches. Anyway, I was looking around and found a ...
0
votes
4answers
285 views

find outputs an extra empty line

Im using the find command to find common files between two directories: find "$SOURCE" "$TARGET" -printf "$TARGET%P\n" | sort | uniq -d problem is it always outputs an empty line on the top. Due to ...
14
votes
1answer
397 views

Linux find command is misbehaving

Searching for system-resolved service following the recent vulnerability disclosure, I came to see a very strange behavior from find command. root@localhost:/# find . -name "*systemd-resolved*" ./...
0
votes
0answers
31 views

Full path not working with find

I use this command to delete all files apart from .htaccess in current directory. find . -depth -name .htaccess -prune -o -delete I want to make a shortcut so I am trying to make it work with fully ...
4
votes
1answer
434 views

Why is L2ARC not giving more speedup for directory traversal?

L2Arc is usually configured to cache random spinning platter reads on an SSD. I've set up this configuration in the hopes of speeding up directory traversal. This is the setup: # zpool list -v NAME ...
0
votes
1answer
271 views

Linux find and -mtime usage

I have two different linux based systems where the find command doesn't seem to be working as expected. I have a directory. In it I run... ls -l and the system returns... drwxr-xr-x 2 panopticon36 ...
0
votes
1answer
54 views

Processing image files once and only once without missing any

I have a wordpress installation with a large number (millions) of images. I want to optimize those images using ImageMagick mogrify but I only want to process them once (processing them over and over ...
10
votes
3answers
2k views

Securely use find with sudo

On a Linux server, I need to remove root privileges from a group of users. But those users have legitimate reasons to be able to use the "find" utility to search for files based on file names, ...
0
votes
1answer
569 views

How to use find to delete hidden files and folders

How can I find and delete all files, including hidden ones, that do not not have the extension java. I know how to use find to delete files and run this command: find . -not -name "*.java" -type f -...
-1
votes
3answers
118 views

Centos find coredump files

I want to use regex to find all coredump files under a directory. The pattern of the file name is core.1234 find /public_html -type f -regextype sed -regex "core.{[0-9]+:[0-9]+}" Please advice.
1
vote
1answer
83 views

Delete all folder not containing filename matching glob/regex

I want to do the following. I have depth 2 file hierarchy like this: A | B | | g | | h50000 | C Where A, B, C are folders. I want to delete all folders without files matching specific patters, (in ...
0
votes
1answer
55 views

Find old files in directory

I'm writing backup rotation script, that suppose to take all files older then 5 days and delete them. Problem is that i've got some weird search results. for example: [root@spr1-nas01 storage]# date ...
-1
votes
1answer
466 views

Find and rm command not deleting recursively

We have a simple scripts that suppose to delete old folders. The problems is that it doesn't delete them recursively. This is the command: find $PWD -maxdepth 5 -mtime +80 | xargs -I{} rm -Rvf {} ...
0
votes
0answers
64 views

linux copy directory over another directory and if the same rename older files appending the modification date-time

In Linux, I am wondering how one can copy (maybe some sort of merge) one directory over the second directory - which can have the same name - and if two file have the same name then rename whichever ...
-3
votes
1answer
112 views

Cloud server running slow

Can anyone help with this: One of our cloud servers is running slow and after running iotop I've noticed the below command running for nearly 2 hours, but I'm the only one who would run commands on ...
0
votes
1answer
84 views

Why does replacing a string in files with find and exec sed not work

Goal is to replace all references to my old email. I tried find /var/www/vhosts/ -name '*.php' -type f -exec sed -i 's/old\@email.com/new\@email.com/g' {} \; Yet it just shows nothing. It goes on ...
-5
votes
1answer
272 views

chmod for all sub directories

There is command that change the folder permission for all subfolders find . -type d -exec chmod 755 {} \; I understand d is for directory and chmod 755 to make all directory as 755 I want to know ...
1
vote
1answer
81 views

find files under subdirectory using find in centos

My current cronjob is * 10 * * * /bin/find /var/spool/record/ -type f -exec /bin/rm {} + It delete all files at 10 AM everyday . I am trying to delete specific file of size less than 90KB type ...
3
votes
1answer
80 views

Find files and tar.gz the resulting list

Executing the following command works as expected: find /path/to/logs/ \( -type f -name '*20161005.log' \) -print0 | tar -czvf /path/to/backups/backup_logs_20161005.tar.gz --null -T - But, trying to ...
2
votes
3answers
55 views

Make find succeed even if there are no matching files

I'm using find in a bash script to clean up some cached files more than a day old: find /tmp/my_files_*.cache -mtime +1 -delete The problem is if the command matches no files it fails which prevents ...
0
votes
1answer
48 views

Remove all files except

Im running a deployment script on my current test environment but at other environments it is way too slow. Below script is running to remove all files and keep only the ones that have to remain: # ...
0
votes
2answers
8k views

Determine which workstations a user has logged on to previously

I would like to find a way to determine what workstations or servers a user account has logged into. Is there a script that can scan a DC for this info? Alternately, any PC a user has logged onto ...
1
vote
1answer
75 views

Linux find utility cannot see fstype of nfs partition

I have 2 debian linux servers that are pretty similar, and mount the same set of nfs partitions. Investigating a problem with find not ignoring nfs partitions when rebuilding the locate db, I found ...
0
votes
2answers
102 views

How to direct errors from with a find exec command to a log file

Hi I have the following command that does yui optimizations and runs as a cron job. I want to log the output of the command to a log file. find . -type d -exec bash -c "cd '{}' && pwd &&...
0
votes
2answers
238 views

Using GREP to Find Text in Files

I'm trying to use grep to find a specific line of PHP code I know for certain is present in several files, but all I get back is an empty result. Please advise on how I need to modify my grep query: ...
1
vote
1answer
1k views

Linux Find File with Exact Size

In the Linux command line, how can I find all files exactly 158 kB in size? I was using the following command but it didn't work: find /var/www/ -xdev -type f -size 158k
1
vote
1answer
84 views

Identifying files being actively written to CIFS share

Is there a way to identify files that are actively being written to a CIFS mount in Linux? I am interested in skipping those files. My first thought would be to fine tune the find command with mmin....
0
votes
1answer
50 views

Source of long running find process on server

I'm wondering where a long running find process on my ubuntu linux server (14.04 LTS) came from and what the meaning of it is. Here is the output of ps: 16915 ? SN 32:41 /usr/bin/find /tmp /...
-1
votes
2answers
883 views

Find all files which contain pattern in directory of tar files

I have all tar files in a directory. I want to find some files in tar files without extract all tar files. I know how to work with one tar file: tar tvf abc.tar | grep xyz I want to find in all tar ...
1
vote
4answers
1k views

How to find directory containing specific files or directories?

I'm looking for a one-line command that find multiple files or directories contained by a single directory. foo -> bar -> baz -> quux temp -> bar I'm looking to only find foo ...
-1
votes
1answer
920 views

Using rsync with StrictHostKeyChecking and find files older than 5 minutes from remote

I would like to use rsync to sync my files from remote to a local directory. Therefor I use StrictHostKeyChecking so that there's no need to enter a password. Now I would like to only sync files ...
3
votes
2answers
10k views

Command find show “Value too large for defined data type”

When I run the "find" command in any folder, works perfect, but only in a particular folder I get this: root#find . find:.: Value too large for defined data type It is a shared folder from another ...
7
votes
1answer
408 views

File is too big for /dev/null

While testing a problem LUN for read errors, I encountered the following problem: find /mnt/problem_lun/ -type f -print -exec dd if={} of=/dev/null bs=8k \; ... /mnt/problem_lun/a_file dd: writing `/...
1
vote
1answer
3k views

Linux find: How to exclude the “.snapshot” directory from find's results?

I wrote a rsync script which uses find command to find all files which are older than 10 minutes and copies them to a remote server. The relevant part of the code is: print_log "------ Starting $0 --...
1
vote
1answer
86 views

Running “find” and piping the output to “wc”/“sort”, inside an outer “find -exec”

I've a folder used by imapsync to store its own cache. Such a folder contains a subfolder for each of the mailbox I'm syncing, and nothing more: [dv@monitor] find * -maxdepth 0 -type d | wc -l 126 [...
0
votes
1answer
120 views

Searching for files containing text (not string) in bash

How do I find files containing some particular text containing newlines and plenty of other charachters all sorts of quotes and backslashes using terminal?