Skip to main content

Questions tagged [find]

search for files in a directory hierarchy

Filter by
Sorted by
Tagged with
0 votes
0 answers
34 views

Is there a reason why I can't use find to scan modified files for viruses and malware? [migrated]

I need to scan Linux systems for viruses/malwares, just entire filesystem. There are few options to consider. One is normally what users do: Use antivirus to scan system once a day. The second option ...
user1578026's user avatar
0 votes
1 answer
23 views

find -print0 doesn't work piped to with xargs -0 when -or conditions are used

I'm trying to "grep" content from a list of files in current directory, matching either asp, html and htm extensions. I am also using cygwin, with: bash: 4.4.12(3)-release, findutils (find ...
Avenger's user avatar
  • 151
0 votes
1 answer
56 views

Remove old files in subfolders and subfolders

I have an ip cam that records videos in a folder structure like this: ├── 2023 │ ├── 10 │ ├── 11 │ │ ├── cam_00_20240921153706.mp4 │ │ ├── cam_00_20240921153928.mp4 │ │ ├── ...
Simon's user avatar
  • 676
1 vote
1 answer
166 views

Linux find - exclude parent directory with some pattern

How I can exclude some parent directory from find output, if it contains some sub-directory name pattern? I have similar directory tree: fnd |-- aaa | `-- 2023.11.12 |-- bbb | |-- 2023.12.12 | `-...
shpeka's user avatar
  • 11
0 votes
0 answers
23 views

Rename folder file with stat output with bash and/or xargs

I have been trying to solve a little renaming problem. With bits and pieces taken from this site, man pages etc. Something fails but I cannot find out what... I have photo files in a folder, with ...
user3450564's user avatar
0 votes
0 answers
98 views

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 ...
Computist's user avatar
  • 483
0 votes
1 answer
544 views

$'\r': command not found error when executing find in a bash script

I wrote the following script; it's modified for simplicity and privacy reasons: FILES_ROOT='/data/FILES' BACK_B2B_RETURNS_S="$FILES_ROOT"'/wms-m-company/w2z/b2breturns/backup' ...
MaestroMaus's user avatar
0 votes
0 answers
1k views

RHEL 9 server with cloned disk unable to find logical volume after boot

We have an RHEL 9 server. We cloned it's disk drive to a new disk. (dd if=/dev/olddrive of=/dev/newdrive bs=4096) It has a couple LVM partitions (as shown on /etc/fstab on the cloned disk): However ...
ServerMan's user avatar
1 vote
1 answer
86 views

extract full path FIND with special character handling

Executing a comand like: find /some_path -mtime -3 -type f -name "*.txt" the out is something like: /some_path/file 1.txt /some_path/file2.txt If I include this output in rsync with ...
Jacopo Nasi's user avatar
0 votes
1 answer
77 views

searching for multiple files, but if one file is missing I want to know from the output + find

$ find ./ -name "AABE*" ## this returns nothing $ echo $? 0 $ find ./ -name "AWGT*" ## this returns locations of were files matching the criteria ./Atempt3A/AWGT-modified.txt ....
HattrickNZ's user avatar
0 votes
1 answer
2k views

Linux find command to return files AND owner of files NOT owned by specified user

I have the following terminal command: find /home/not_this/ \! -user not_this_user_account The goal is to find all the files and directories not owned by the specified user and this version of the ...
John's user avatar
  • 138
1 vote
1 answer
374 views

how to exclude folders by date with find?

This is "myfolder": tree -a 'myfolder' myfolder ├── 20220902 │   ├── filefoo │   └── filebar ├── 20221001 │   ├── filefoo │   └── filebar └── 20221015 ├── filefoo ├── filebar └── ...
acgbox's user avatar
  • 408
1 vote
1 answer
79 views

how to extract values from files, compare it with a variable and send to out file

I have myfolder with this files: ls myfolder filefoo filebar filefoobar For example, the content of filefoo is: total: 379400041 cache_object://localhost/active_requests 379400041 6778 0-...
acgbox's user avatar
  • 408
0 votes
0 answers
649 views

How to rsync files/folder from some days ago?

I would like to run cron job that run rsync command to copy files from 3-4 days ago, I've already try some rsync command like this: rsync -arogzv --ignore-existing --files-from=<(find . -type f,d -...
Hidayat Taufik's user avatar
0 votes
1 answer
842 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 ...
Ric Treepusher's user avatar
0 votes
1 answer
10k 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 ...
adnan ijaz's user avatar
0 votes
0 answers
36 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/...
grU's user avatar
  • 1
0 votes
1 answer
114 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 ...
David's user avatar
  • 1
0 votes
1 answer
631 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 ...
Displayname71's user avatar
0 votes
1 answer
77 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"
Iluvatar's user avatar
  • 121
-1 votes
1 answer
172 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 ...
medk's user avatar
  • 111
0 votes
0 answers
70 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 ...
Helmut Emmelmann's user avatar
0 votes
1 answer
411 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: ....
Alex Douglas's user avatar
0 votes
0 answers
506 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.
StevieD's user avatar
  • 572
0 votes
1 answer
2k 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 ...
nasa's user avatar
  • 1
0 votes
1 answer
937 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 ...
Loz's user avatar
  • 1
0 votes
1 answer
137 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\...
Thom's user avatar
  • 41
4 votes
1 answer
883 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 ...
Spot's user avatar
  • 266
0 votes
1 answer
246 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 ...
Alex Douglas's user avatar
0 votes
2 answers
461 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 &...
PawelC's user avatar
  • 199
0 votes
2 answers
83 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 ...
n4rzul's user avatar
  • 103
0 votes
1 answer
198 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 ├─...
QB new media's user avatar
0 votes
1 answer
169 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 '%...
James B. Byrne's user avatar
0 votes
1 answer
144 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 ...
learningtech's user avatar
  • 7,659
0 votes
2 answers
2k 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 ...
Edward_178118's user avatar
0 votes
1 answer
984 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 ...
Ginger's user avatar
  • 103
0 votes
0 answers
99 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 ...
Oskar Calais's user avatar
0 votes
1 answer
2k 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 ...
learningtech's user avatar
  • 7,659
2 votes
1 answer
420 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 ...
alexfvolk's user avatar
  • 174
2 votes
1 answer
827 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 ...
learningtech's user avatar
  • 7,659
1 vote
1 answer
2k 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 - ...
Vladimir Knysh's user avatar
1 vote
1 answer
816 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. ...
emesik's user avatar
  • 113
0 votes
0 answers
100 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 ...
guettli's user avatar
  • 4,123
0 votes
1 answer
342 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 [email protected] but results will be ...
JackTheKnife's user avatar
3 votes
2 answers
3k 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 ...
user3200534's user avatar
0 votes
1 answer
253 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/...
Patrick Rynhart's user avatar
0 votes
1 answer
67 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 ├─...
gogasca's user avatar
  • 343
0 votes
2 answers
688 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 ...
Niclas H's user avatar
0 votes
1 answer
49 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 (...
Vince's user avatar
  • 391
0 votes
1 answer
172 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/...
Parapluie's user avatar
  • 165

1
2 3 4 5
7