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
0
votes
3 answers

How to add a new line (\n) between each file being concatenated

How should I modify this line to add a new line (\n) between each file being concatenated? find /disk/data/source/* -name '*.xml' -exec cat {} \; > /home/userid/merged-file.xml
user3489502
  • 3,451
  • 9
  • 38
  • 66
0
votes
1 answer

Why can't I exclude a directory using find

I attempting to run a command on all subdirectories in a directory using find and -exec, however on one of the directories, the user the script runs under does not have adequate permissions and I get an error (permission denied). I am attempting to…
arowland
  • 1
  • 1
0
votes
3 answers

Linux: find file names with 4 or 5 characters

How can I find file names consisting of either 4 or 5 characters? For file names with 4 characters, I can use find . -name ????.tgz, but how to I expand this to length either 4 or 5?
0
votes
2 answers

Identifying either of two different substrings in the filename using Regex?

When I run my script, I specify a pattern I'm looking for in the files located in the source directory. Pattern can be located anywhere in the filename. When I do: sh packageScript.sh -p ".*TOM.* The script works as desired and all the files with…
user9526185
0
votes
1 answer

Find files in directory modified at various times

Bash newbie here. The task is to find all files in a (rather large) directory whose modification date falls between various pairs of times. These times are specified as Unix timestamps in a CSV…
0
votes
1 answer

find regex with date range in filename

I've files in a folder like file_2017-01-01.jpg file_2017-02-20.jpg file_2017-05-10.jpg file_2017-09-01-jpg file_2017-10-25.jpg file_2017-11-04.jpg file_2017-12-22.jpg How can I use the find command to list files from…
0
votes
0 answers

How to define the GNU find command in Gradle?

I have this command find path/tools/ \( -name '*.sh' -o -name '*.exe' -o ! -name "*.*" \) -exec chmod +x {} \; How can I define it in my Gradle exec task? task xPermTools (type: Exec){ workingDir '../' commandLine "find", "path/tools/",…
Müller
  • 973
  • 6
  • 19
  • 38
0
votes
2 answers

Delete only Directories (not files) older than x days in Linux

I am trying to list the directories (but not files) older than x days. I used below command to do it. But it is listing directories and files. Could anyone help me in resolving it? Thanks. find /path/to/base/dir/* -type d -ctime +10 -exec ls {} \;
sunil
  • 65
  • 3
  • 11
0
votes
2 answers

What do {} and \ mean in 'sudo find /var/www/html -type d -exec chmod g+s {} \;'

I'm running the command sudo find /var/www/html -type d -exec chmod g+s {} \; from here It's said there that "We can set the setgid bit on every directory in our WordPress installation by typing the above command". The question is what do {} and /…
rok
  • 9,403
  • 17
  • 70
  • 126
0
votes
1 answer

missing argument to -exec

I am having a problem with a bash command returning the following error: /usr/bin/find: missing argument to `-exec' The actual command I am running is: /usr/bin/find /backup-directory/ -maxdepth 1 -type f -mtime +14 -printf "%f\n" -exec…
Sheldon
  • 13
  • 2
0
votes
1 answer

How to find directories older than date when the date is encoded to dirname as yyyy-mm-dd

I want to purge old folders with all the content by GNU find. I'm familiar with -mtime but the time stamp of the directories is usually corrupted by rsync - not important. Luckily, the time stamp is encoded to the directory name as yyyy-mm-dd. How…
SkyRaT
  • 285
  • 3
  • 6
0
votes
1 answer

directory-first-search with find

When find iterates directories, they show up in the order the VFS yields them. Can this order be changed to first traverse directories before looking at files placed beside them? The -depth option is not the solution. It only changes $…
XZS
  • 2,374
  • 2
  • 19
  • 38
0
votes
0 answers

GNU find and more complex -exec option parameter values

This works for me: $> find . -name "*.log" -exec basename '{}' \; 20160114.log 20160115.log 20160116.log 20160117.log 20160118.log Is the {}, \ and ';' mandatory when using -exec as any other syntax simply doesn't work? The following, more complex…
msciwoj
  • 772
  • 7
  • 23
0
votes
0 answers

Issue with find command of linux

Continuously getting so many warnings yet my command is working fine. find: `api/PlayersImpl0.smali': No such file or directory find: `api/PlayersImpl1.smali': No such file or directory find: `api/TurnBasedMultiplayerImpl0.smali': No such file or…
Puneet
  • 440
  • 3
  • 8
0
votes
5 answers

Find the name of subdirectories and process files in each

Let's say /tmp has subdirectories /test1, /test2, /test3 and so on, and each has multiple files inside. I have to run a while loop or for loop to find the name of the directories (in this case /test1, /test2, ...) and run a command that processes…
Young
  • 43
  • 1
  • 11