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

findutils 4.4.x on Ubuntu does not let me specify the `depth` option

Mission: List all direct decendants of a directory that are a directory itself. On BSD (Mac OS), find . -type d -depth 1 works. This is the output of Ubuntu 12.04 (GNU findutils 4.4.2): $ find . -type d -depth 1 find: warning: you have specified the…
Thomas Keller
  • 5,933
  • 6
  • 48
  • 80
2
votes
1 answer

GNU Parallel not completing all "find" commands

I'm trying to parallelize a command without success, there are about 100 video files to convert. This format resulted in 8 files being converted in a random order: parallel -j 8 videoConvert ::: `find "/mnt/bulk-data-02/videos/convert" -iname…
2
votes
1 answer

gnu parallel + sed to edit both csv header and contents

I'm trying to use command line tools to edit some CSV I have in the following format for several year folders: dataset year_1 (i.e. 1929) csv_filename_1.csv csv_filename_2.csv csv_filename_3.csv ... year_2 ... I'm trying to append the…
paulochf
  • 690
  • 2
  • 11
  • 21
2
votes
1 answer

Bash "gnu-find" + "gnu-parallel" in --pipe mode and executing cmds with some files having space(s) in their names

I seem unable to fix my space in filenames issue using switches like -print0 for gnu-find and -0 for gnu-parallel, gnu-xargs in this scenario as is usually recommended. I succeeded in combining find, parallel in pipe mode and xargs to run commands…
2
votes
0 answers

Implicit -a in find expression

From the find manpage: Please note that -a when specified implicitly (for example by two tests appearing without an explicit operator between them) or explicitly has higher precedence than -o. This means that find . -name afile -o -name bfile…
Malory
  • 21
  • 1
2
votes
1 answer

Linux CLI find dir paths without their children - only parent paths as a result

I have this dir tree: /tmp/find-test/ ├── one │   ├── abc │   │   ├── one │   │   └── two │   └── def │   ├── one │   └── two └── two ├── abc │   ├── one │   └── two └── def ├── one └── two and the same for…
Jimmix
  • 5,644
  • 6
  • 44
  • 71
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
1 answer

a bug in findutils about case insensitive?

There is a file named foo.js in the current folder. I use find to search : tigerlei::~/work $ ll foo.js -rw-rw-r-- 1 tigerlei tigerlei 187 Mar 29 2017 foo.js tigerlei::~/work $ find . -regex '.*/foo.*.j[R-T]+' -regextype…
TigerLei
  • 23
  • 3
2
votes
2 answers

tar cpf for the most recent file in directory with progress

I'm looking for the easiest way to tar the most recent file in directory. The command below locates the correct file, but I don't know how to tar it from the output: find /home/user -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d"…
faceless
  • 450
  • 4
  • 15
2
votes
2 answers

Batch-process files with find in multiple directories

I have a directory with several subdirs which contain .flac files. I want to batch convert them to .mp3. The path names contain spaces. Now I want to do something like this find . -type f -regex .*.flac -exec ffmpeg -i {} -c:a mp3 -b:a 320k \; But…
oarfish
  • 4,116
  • 4
  • 37
  • 66
1
vote
2 answers

Why is find returning a directory with -type f?

I'm doing some crude code analysis and I've noticed some weird error lines in my output: cat: rust/library/portable-simd/crates/test_helpers: Is a directory cat: rust/library/core/tests/iter/adapters: Is a directory cat:…
Banyoghurt
  • 195
  • 11
1
vote
2 answers

sed on many files - can we do better than invoke-once-per-file?

I have a set of > 100,000 files to which I want to apply a sed script. Reading the accepted answer to this question: Applying sed with multiple files I see the suggestion involves invoking sed for every single one of the files one is interested in,…
einpoklum
  • 118,144
  • 57
  • 340
  • 684
1
vote
2 answers

Remove empty files and save a list of deleted files

I need a script that removes all empty files and writes a list of deleted files to a text file. Deleting files works. Unfortunately, the listing does not work. find . -type f -empty -print -delete I tried something like this: -print >> test.txt
1
vote
1 answer

find directories and change ownership using bash

I am trying to find directories older than 150 days and change their ownership as root. Please can you advice on how do i fix the below pls? find /mnt/mailfolder/ -maxdepth 1 -type d -mtime +150 -printf "%P\n" -exec "chown -R oracle:oinst find:…
nick
  • 99
  • 7
1
vote
2 answers

Using find to find files WITH a certain pattern and not other pattern

I want to use find to find files with _101_ in the name and not .jpg or .wsq extensions, but I cannot get this to work. I tried things like this: find . -type f -name '*_101_*' -o -not -name *.jpg -o -name *.wsq but it doesn't work. What am I…