Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Questions tagged [find]

search for files in a directory hierarchy

Filter by
Sorted by
Tagged with
0 votes
1 answer
21 views

Failing string replacement in xargs command

I am trying to automatically create symlinks to directories and to replace a certain text string (foo) of the original name in the link name (bar). The name of the target directories may contain ...
user avatar
0 votes
0 answers
7 views

mtime vs msec producing different result

I've setup a little cron to compress log files of my application. Generally I need todays logs, so I can compress everything that is one day old or older. Why do the two following commands behave ...
user avatar
  • 164
0 votes
1 answer
245 views

Where to find the website folder in ubuntu server?

So someone gave me the task to find where is the website code exist on ubuntu server when I look at the the index.html file path it is /var/www/example.com/html but when I go to /var/www directory I ...
user avatar
0 votes
0 answers
35 views

locate all nested war/jar files inside jboss/wildfly - log4j [duplicate]

I want to detect all nested wars and jars containing the log4j library. I have jboss/wildfly services. I started to find out with 'locate | grep', but it shows me only tmp directories, not exactly war/...
user avatar
  • 1
0 votes
1 answer
48 views

Removing old files from home directories

I need to find and remove files older than 2 weeks from the home directories of my cluster. I do not want to let people just "touch" the file to change the modification date and keep it for ...
user avatar
  • 1
0 votes
1 answer
76 views

How can I search for symlinks that point to other symlinks? [closed]

I have morass of chained symlinks like this scattered around: A (symlink) -> B (symlink) -> C (file) Some may even involve longer chains, I'm not sure yet. When manually examining a single file ...
user avatar
0 votes
1 answer
70 views

How to search for a file when 'find' is not an option

Is there a good way to search for a file if you are for ex. stuck in dracut/initrd? The only thing that I was able to do was: ls /**/**/**/**/* | grep "file name"
user avatar
  • 121
-1 votes
1 answer
27 views

Linux Delete Files Older Than and the Same Time Smaller Than

I use this command to delete MP3 files older than 90 days. find MP3/ -type f -name "*.mp3" -mtime +90 -delete I want to make it delete those older than 3 days but with file size less than ...
user avatar
  • 101
0 votes
0 answers
65 views

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 ...
user avatar
0 votes
0 answers
21 views

How can i find files and directories with incorrect permissions(perm that i don't not want) and then change only those

I am sure there is an easy way of doing this either with a script or possibly with a one-liner, which would be great. basically, i want directories to be changed to 775 only if perm doesn't currently ...
user avatar
  • 1
0 votes
1 answer
57 views

Cron to find multiple file types and automatically delete them

I am trying to put together a command that will find multiple file types and automatically delete them. I want to run this in a cron every 10 minutes on my server. I would like to find files of type: ....
user avatar
0 votes
0 answers
180 views

find: invalid argument `2s' to `-mtime'

This works: find /home/example -mtime 2 This doesn't: find /home/example -mtime 2s Read the man page but looks like I'm doing it right AFAICT.
user avatar
  • 412
0 votes
0 answers
58 views

Move files older than day

I am looking for some solution, where I have to move all the directories and files under the source directory to the destination a day before. I want to move the directories till yesterday but not ...
user avatar
  • 1
0 votes
1 answer
147 views

Using find -exec in systemd ExecStartPre

I think it's fairly obvious what I'm trying to do here # Rename Log File ExecStartPre=/bin/find /data/db/log/*.log -type f -exec mv {} {}.`date +"%Y%m%d-%H%M"` \; # gzip past log files (is ...
user avatar
  • 1
0 votes
1 answer
65 views

Find and Replace using Regular Expression

I try to find a way to find and replace using EMEditor and a Regular Expression. I try to applu this for the item below: <?php /*f04b8*/ @include "\057mn\164/r\141id\057ho\155e/\164ap\151om\...
user avatar
  • 31
2 votes
1 answer
488 views

rsync remote find prefixes home directory?

I am attempting to pull everything from a remote directory which is more then ten minutes old, and then remove the source files. My remote find seems to be working (tested independently on the remote ...
user avatar
  • 246
0 votes
1 answer
76 views

I want to run a command every 10 minutes in crontab on a certain directory [duplicate]

Running a server with Ubuntu 18.04 I am attempting to run this command every 10 minutes in crontab on the directory /var/www/html: find . -type f -name "*.maintenance" -delete Is this the ...
user avatar
0 votes
2 answers
193 views

Find with regex not working on CentOS 7 [closed]

I have problem with find and regular expression. I would like to find files in /etc, which name begin of a or b. I tried this commands: find /etc -type f -regex '^a' find /etc -regextype sed -regex &...
user avatar
  • 119
0 votes
2 answers
38 views

Making a copy of all .acignore->.gitignore in place, recursively

I have the following file structure as an example c -Git -GitBranchTest .acignore [lots more files] -subfolder .acignore [lots more files] I am ...
user avatar
  • 103
0 votes
1 answer
75 views

List all files with corrupt filenames recursively

I've got a Linux server with some directories and files structure on it. Apparently somehow someone uploaded a bunch of filenames, which got corrupted. Consider the following example: └── parent ├─...
user avatar
0 votes
1 answer
40 views

I need bash find behaviour explained when using -newermt and -exec ls {}

I have this command: find /var/cache/pkg -newermt 2020-01-30 | grep 'kdeaccessibility-4.14.3_1' Which returns nothing. I change it to this: find /var/cache/pkg -newermt 2020-01-30 -exec ls -D '%...
user avatar
0 votes
1 answer
53 views

Prune does not ignore top level directory of what I specified

When I do this mkdir -p a/b/c mkdir -p a/d/e find ./a -path ./a/d -prune -o -type d I get this: ./a ./a/d ./a/b ./a/b/c I must be using the prune flag wrong. How do I ignore the directory ./a/d as ...
user avatar
  • 7,033
0 votes
2 answers
328 views

Can you cache the 'find' command?

I wrote a simple shell script which uses the 'find' command so non-technical users can do a search on the file server through a web browser on the LAN. It works, but sometimes it has a long execution ...
user avatar
0 votes
1 answer
184 views

crontab not working for deleting a old files from log folder

I have this line in my crontab to delete old files: 1 * * * * find /var/log/abc/ -mtime +7 -type f -delete Unfortunately, it does not work. I have attempted to give all users permission to clear ...
user avatar
  • 103
0 votes
0 answers
41 views

BAT script to return server licenses at shutdown?

My office uses program licenses that have to be manually activated and returned, and people tend to forget to do this when they go home for the day, resulting in most licenses tending to be ...
user avatar
0 votes
1 answer
890 views

using find, exec and cp to copy specific files while preserving directory path

I set up the following folders with empty text files: 1/a.txt 2/b.txt I want to copy only txt files to another directory while maintaining their directory structure. So I tried the following ...
user avatar
  • 7,033
2 votes
1 answer
110 views

Best strategy for daily back up of terabytes of data with millions of files

Currently I create an NFS and mount it on a special server that does the actual backups and uploads it to s3. My main concern is I feel like overcomplicated this simple task. I schedule cron job to ...
user avatar
  • 164
2 votes
1 answer
276 views

Dropping the -print0 and -0 flags from find and xargs

Almost 10 years ago, I asked this question use SED recursively in linux? and got this useful command find . -type f -print0 | xargs -0 sed -i 's/regex_search_term/replace_term/g' I decided to learn ...
user avatar
  • 7,033
1 vote
1 answer
874 views

Ansible find and delete JDK folders

we have path and different folders inside adobe_tools_path: "/apps/cq5/tools/" is it possible to delete only *JDK pattern folders via loop? my playbook is not matching JDK folders as a pattern - ...
user avatar
0 votes
1 answer
170 views

How to `find` files not being open by any process

I have several cron tasks, each of which leaves a separate log file. Successful tasks generate no output, so I'm getting a lot of empty logs. I'd like to clean it up automatically every day. ...
user avatar
  • 103
0 votes
0 answers
31 views

find: `var/cache/django/...': No such file or directory

This cron job: @daily find var/cache -mindepth 2 -maxdepth 2 -mtime +14 -exec rm -rf {} + Creates sometimes error messages like this: find: `var/cache/django/bfcfd153d35a27eb78823.djcache': No such ...
user avatar
  • 2,914
0 votes
1 answer
232 views

Sudoer with permission denied

I have a user in sudoers which has entry like user ALL=(ALL) NOPASSWD: /usr/bin/find then that user will try to do /usr/bin/find /var/mailboxes -iname mailbox@domain.net but results will be ...
user avatar
2 votes
2 answers
1k views

How to add the filename as prefix to each line of the text file? (batch processing; subdirectories)

I have many .txt files with their filenames being different dates: 01.01.2010.txt 02.01.2010.txt ... Currently each file (e.g.: 01.01.2010.txt) looks like this: 0.351 XXX XXX XXX XXX 0.292 ...
user avatar
0 votes
1 answer
161 views

Why can't unix find enumerate everything beneath /sys?

I'd like to be locate every device that has a rescan option/file beneath /sys/devices (so that I can resize disks on the fly), but UNIX find doesn't seem to find them. For example: # file /sys/class/...
user avatar
0 votes
1 answer
36 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 ├─...
user avatar
  • 313
0 votes
2 answers
392 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 ...
user avatar
0 votes
1 answer
24 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 (...
user avatar
  • 371
0 votes
1 answer
99 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/...
user avatar
  • 145
1 vote
3 answers
919 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
user avatar
1 vote
1 answer
273 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 ...
user avatar
  • 657
3 votes
2 answers
117 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 ...
user avatar
1 vote
0 answers
103 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/...
user avatar
1 vote
0 answers
587 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 ...
user avatar
  • 111
3 votes
1 answer
5k 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 ".*\.(...
user avatar
0 votes
1 answer
34 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 ...
user avatar
0 votes
1 answer
852 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 ...
user avatar
1 vote
4 answers
299 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 ...
user avatar
14 votes
1 answer
451 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*" ./...
user avatar
0 votes
1 answer
88 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 ...
user avatar
  • 193
5 votes
1 answer
740 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 ...
user avatar

1
2 3 4 5
7