Questions tagged [gnu-findutils]

GNU's basic directory searching utilities (Unix filesystem CLIs)

The GNU Findutils package comprises the following CLIs, which relate to finding directories and files on Unix systems:

  • find - search for files in a directory hierarchy
  • locate - list files in databases that match a pattern
  • updatedb - update a file name database
  • xargs - build and execute command lines from standard input

Linux distributions typically come with find and xargs from this package; while locate and updatedb are typically also present, they may come from a different source.

See http://www.gnu.org/software/findutils/

82 questions
1
vote
1 answer

Bash: copying files with find, naming them with progressive numbers

I am trying to write a script to copy all files in a directory tree to another directory, using find command. However, some files have the same name as other. Since I am not interested in file names at all, I thought that the simplest solution would…
Ajeje
  • 396
  • 2
  • 5
1
vote
2 answers

how to ignore directory in find by full path

I want to write a function that will find files in current directory I'm currently in. The thing is that if I'm in /home, I want to find files in sys, dev and var directories (which is in my home folder). But If I'm in root folder I wish them to be…
sandric
  • 2,310
  • 3
  • 21
  • 26
1
vote
1 answer

Rename files with space with very large directory structure

I've already read through and tried many of the answers here for how to rename files with spaces in a nested directory structure. However, they do not seem to work for my situation. They all segfault. I have just shy of 1,000,000 files in a…
Blake Senftner
  • 756
  • 1
  • 8
  • 24
0
votes
1 answer

Exit 1 if there any output, otherwise 0

I have the following line on a GitHub Action: find kubernetes-manifests -regextype egrep -regex '.*ya?ml$' -exec kubeconform "{}" \; Unfortunately, kubeconform doesn't return 1 or anything else on errors; it is always 0 and some message. Is it…
Rodrigo
  • 135
  • 4
  • 45
  • 107
0
votes
1 answer

How to find all files that match a regex and store the result in a variable?

I have this code so far: #!/bin/bash list=$(find "$(dirname "$0")/../temp/" -regex "(part.[a-z])") echo "$list" I want to find all files in the temp directory that have a file name like this: part.aa part.ab part.aaa part.qqk current path…
Omar Dulaimi
  • 846
  • 10
  • 30
0
votes
1 answer

Does GNU find protect against finding a file multiple times if files are renamed with xargs or -exec?

I used the following command to add a prefix to all filenames in the current directory: find . -maxdepth 1 -type f | xargs -I {} basename {} | xargs -I {} mv {} prefix-{} My question is: is this procedure safe with GNU find? Or could the find…
Frank
  • 1,565
  • 1
  • 10
  • 9
0
votes
2 answers

Unable to pass output of find to image magick

For some images in a directory as follows: Atlas_21YearNova59_add_main.png Atlas_21YearNova59_add_mask.png…
0
votes
2 answers

Trying to use GNU find to search recursively for filenames only (not directories) containing a string in any portion of the file name

Trying to find a command that is flexible enough to allow for some variations of the string, but not other variations of it. For instance, I am looking for audio files that have some variation of "rain" in the filename only (rains, raining, rained,…
derrgill
  • 15
  • 5
0
votes
1 answer

Can anyone spot where I'm going wrong when creating an array in bash?

I'm creating a shell script to find and delete screenshots saved on my desktop. I'm trying to use mapfile to create an array of file paths. However I'm struggling to manage it as my current code creates an array that has only a single element! Worth…
user18685969
0
votes
1 answer

GNU findutils doesn't find file

When searching for .txt files that are in 2 different home directories only one shows up depending on the present working directory. Why is this? /home/bob/1.txt /home/alice/dir1/2.txt pwd /tmp [root@host tmp]#find /home -name *.txt…
Demi
  • 47
  • 3
0
votes
1 answer

Find util not found on OSX

I'm trying to run a make file that uses the find command. I'm getting an error saying make[3]: find: Command not found. I've tried installing findutils using brew but it's still not working. ~/.zshrc eval "$(rbenv init -)" eval "$(pyenv init -)" #…
Antarr Byrd
  • 24,863
  • 33
  • 100
  • 188
0
votes
0 answers

Bash: Find command with multiple -name variable

I'm using this solution https://stackoverflow.com/a/10341883/6400605 to get a list of files from a specified folder, with a predefined -name variable, but it does not work when supliying a directory argument. #!/bin/bash if [ -n "$1" ] && [ -f "$1"…
jkeys
  • 113
  • 8
0
votes
0 answers

Why does GNU find match files it's told not to? (in a big query)

I have a GNU find command find . -type l,f ! -path './bin/ash' <600 more condition like ! -path './bin/mv'> -printf "rm %P\n" which runs in a directory with a bin/ash file (a symlink). Problem: find prints rm bin/ash. Why does it do it? find is…
Victor Sergienko
  • 13,115
  • 3
  • 57
  • 91
0
votes
1 answer

How does `find -name "*.sh" -exec chmod +x \{\} \;` work?

I found an old one-line shell script: find ./../ -name "*.sh" -exec chmod +x \{\} \; I understand it grants execution rights on all the shell scripts in the directories below the parent directory. However, I haven't seen the syntax \{\} \;…
Blaisem
  • 557
  • 8
  • 17
0
votes
1 answer

in find, `-type d` get files an not only directories if used with `-prune`

I use this: $ find . -type d \( -path './2018*' -o -path "./S*" \) -prune\ -o -print to get all directories (-type d) excluding 2018, S1 and S2 The exclusion of directories work but I get plenty of…
user3313834
  • 7,327
  • 12
  • 56
  • 99