Questions tagged [find]

search for files in a directory hierarchy

Find is used to look files in a directory hierarchy. You can refer to its manpage here.

Examples:

Look for all files on a server owned by user siegfried:

 find / -user siegfried

Find all files ending in php en remove them:

 find / *.php -exec rm '{}' \;
314 questions
0
votes
1 answer

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 another 2 weeks. (I'm talking about files of several…
David
  • 1
  • 1
0
votes
1 answer

How can I search for symlinks that point to other symlinks?

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 it's easy to see what's going on but I'm looking for an…
Displayname71
  • 109
  • 1
  • 7
0
votes
1 answer

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
  • 121
  • 5
0
votes
0 answers

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 got corrupted on the target machine. The background…
0
votes
1 answer

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: .swp, .save, .swo, .maintenance and .bak Here is…
Alex Douglas
  • 353
  • 1
  • 5
  • 12
0
votes
0 answers

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
  • 514
  • 8
  • 24
0
votes
1 answer

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 today’s. find /temp/source/* -mtime +1 -exec mv -t…
nasa
  • 1
  • 2
0
votes
1 answer

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 post becuase might take a long time) ExecStartPost=/bin/find…
Loz
  • 1
0
votes
1 answer

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:
0
votes
1 answer

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

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 correct syntax to accomplish this? */10 * * * *…
Alex Douglas
  • 353
  • 1
  • 5
  • 12
0
votes
2 answers

Find with regex not working on CentOS 7

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 "^a" find /etc -regextype egrep -regex '^a' find…
PawelC
  • 149
  • 1
  • 11
0
votes
2 answers

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 trying to make a copy of all the .acignore files…
n4rzul
  • 103
  • 2
0
votes
1 answer

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 ├── foo1.jpg ├── f+�o2.jpg └──…
0
votes
1 answer

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 '%F' -l -t -r {} \; | grep…
James B. Byrne
  • 337
  • 1
  • 4
  • 14
0
votes
1 answer

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 well from the output of my find?
John
  • 7,343
  • 23
  • 63
  • 87
1 2 3
20
21