Questions tagged [find-util]

The standard Unix utility named "find" for walking file hierarchies in order to find or process files. When using this tag, please add a tag to identify the platform.

find is a standard Unix utility (CLI) mandated by POSIX for walking file hierarchies based on a variety of criteria in order to find matching files or execute commands on them.

The find implementations found on modern Unix platforms typically implement extensions to the POSIX specification for find.

It is fine to use this tag even for questions involving platform-specific extension to find, as long as you also add a tag identifying the platform.

21 questions
182
votes
10 answers

Search for executable files using find command

What type of parameter/flag can I use with the Unix find command so that I search executables?
well actually
  • 11,810
  • 19
  • 52
  • 70
7
votes
2 answers

Why is my `find` command giving me errors relating to ignored directories?

I have this find command: find . -type f -not -path '**/.git/**' -not -path '**/node_modules/**' | xargs sed -i '' s/typescript-library-skeleton/xxx/g; for some reason it's giving me these warnings/errors: find: ./.git/objects/3c: No such file or…
user5047085
5
votes
1 answer

find - mtime vs mmin - Weird results

So I am working on a bash script to purge out temp files and ran into inexplicable behavior. # Find using mmin flag find /usr/local/store/file/temp/3_day/ -mmin +$((60*24*3)) -type f > /tmp/old_files_by_mmin.txt # Find using mtime flag find…
Mike Purcell
  • 19,847
  • 10
  • 52
  • 89
4
votes
1 answer

Recursively search directory of binary files for hexadecimal sequence?

The current commands I'm using to search some hex values (say 0A 8b 02) involve: find . -type f -not -name "*.png" -exec xxd -p {} \; | grep "0a8b02" || xargs -0 -P 4 Is it possible to improve this given the following goals: search files…
Helen Che
  • 1,951
  • 5
  • 29
  • 41
4
votes
1 answer

How to change filename extensions in subdirectories on Mac OS X

I have been trying to iterate though a directory structure where I want to change the file extension from .mv4 to .mp4. The problem is that there are spaces in many of the file names, and I have not been successful in iterating the directory…
svjim
  • 191
  • 1
  • 12
2
votes
0 answers

Why is this non-recursive "find" much slower than searching output of "ls"?

I wrote two different script as below: # Script 1: current_date=$(date +"%m-%d-%Y") logsPath="/hadoop_common/smallsite/realtime/current/spark/logs" find $logsPath -maxdepth 1 -name "*$current_date*" -print > tmp and # Script 2: current_date=$(date…
X625
  • 93
  • 7
2
votes
2 answers

bash find, only delete files - order of arguments

Say today is April 8th and I execute the following in bash. cd /tmp mkdir hello touch -d 2015-04-01 hello Then, say I want to delete all files in /tmp that are older than one day, but NOT directories and I execute this: find /tmp -mtime +1 -delete…
Josh Nankin
  • 2,518
  • 4
  • 28
  • 45
1
vote
2 answers

bash find command with path as requirement

I want to get file names of files in /bin that contain letter 'm' using find command not beeing in /bin. When /bin is my working directory it works fine but when I add /bin as requirement in path it returns nothing independently of current…
flis00
  • 37
  • 6
1
vote
3 answers

Bash: Fail to use find -exec

When using scp or rsync I often fail to deal with 'Argument list too long' error. When having to mv or rm, I have no problem to use find and xargs but I fail to understand how to use find and -exec despite all the SE posts on the subject. Consider…
Remi.b
  • 17,389
  • 28
  • 87
  • 168
1
vote
1 answer

Using bash shell on RHEL 7 - why does find find more files when I don't use -exec?

I'm looking for all setuid/setgid files. When I don't use -exec, it works as expected: # find /usr/bin -type f -perm -4000 -o -perm -2000…
roartechs
  • 1,315
  • 1
  • 12
  • 15
1
vote
2 answers

What would be the fastest way to find and remove files?

With: Find="$(find / -name "*.txt" )" du -hc "$Find" | tail -n1 echo "$Find" | xargs rm -r If the file foo bar.txt is found, it won't count it with du or remove the file. What would be the best way to escape the spaces?
user5849928
1
vote
3 answers

search files in current directory whose name do not contain "txt" in linux

I know how to find files with suffix .txt in the current directory: find *.txt How do I invert this? I am new to Linux, so please help. Thanks!
Big_t boy
  • 299
  • 1
  • 5
  • 18
0
votes
1 answer

Find numbered subdirectories below number X and delete them

I have a folder 'masterfolder' that has subfolders with a numbered naming scheme: \masterfolder\S01 \masterfolder\S02 \masterfolder\S03 \masterfolder\S04 \masterfolder\S05 Now I want to find and delete all folders below a specific number, for…
zilexa
  • 11
  • 3
0
votes
1 answer

How can I find files where ctime and mtime differ?

Sometimes, a site is hacked and the intruder hides the new or modified files, changing the file's date (mtime). Usually, they set it to a not recent date. Using something like find . -type f -ctime -3 -exec ls -ls {} \; I can find files that have…
PaulVM
  • 1
0
votes
1 answer

How can I return a list of hidden files readable by the current user in bash without using the -readable flag?

I want to run a command that outputs all the hidden files the current user can read - in Bash. So far, I am using the find command, with -perm but I can't seem to get files the current user can read, but files a member of current user's GROUP can…
berzerk0
  • 11
  • 6
1
2