Questions tagged [find]

For questions pertaining to find, a command-line utility to search for files in a directory hierarchy. Use this tag for questions about find itself or questions about issues arising from using the find command-line utility.

Filter by
Sorted by
Tagged with
0 votes
1 answer
28 views

Toggling off verbosity in the find command

I'm trying to toggle off the verbosity of the find command while writing the results to a text file and sending the process to the background. I'm using this command: find / -ctime 7 1> /home/user1/...
user avatar
0 votes
0 answers
26 views

scan all directories and subdirectories for .php file output filter with grep

i need to check all php files for error. so i run this command find . -iname '*.php' -exec php -d error_reporting=1 '{}' \; it works well but i want to show just output that start with PHP Fatal ...
user avatar
1 vote
2 answers
33 views

Script to find all empty git repositories on a machine

We know an empty git repository only has the .git directory in it. I want to find all git repositories on a machine, which are empty. I thought about this process: Find all directories that are named ...
user avatar
1 vote
3 answers
46 views

Recursively list path of files only

Why I have two folders that should contain the exact same files, however, when I look at the number of files, they are different. I would like to know which files/folders are present in one, not the ...
user avatar
  • 13
3 votes
1 answer
94 views

Editing only files which match a precondition using jq and find

I have a fair number of JSON files that have different versions as a property. I want to modify files that only match a certain predicate. This is follow-up to in-place editing with find and jq. This ...
user avatar
  • 187
1 vote
1 answer
27 views

In-place editing with find and jq yields inconsistent results

I am trying to use jq to modify a fairly large number of files if the file contains a property of a certain value: find . \ -name '*.configuration.json' \ -type f -exec bash -c 'jq "...
user avatar
  • 187
0 votes
1 answer
19 views

Cannot source file using find, fzf, and xargs

I am trying to use fzf to select and activate different virtual environments. However, I am receiving the follow error: xargs: source: No such file or directory My command comprises three parts: find |...
user avatar
2 votes
2 answers
309 views

can you modify the filename during "find"

find uses {} to indicate "this file"(ish). You can feed a series of files into myprog, thus: find ./tests/ -name *.in -exec myprog -i {} \; Is there a way to modify the name in {}? In my ...
user avatar
1 vote
2 answers
65 views

find: only delete files which we're allowed to delete

I'm using find to delete files matching some criteria: find -type f [more criteria] -delete That works fine, in general, but I'm running into issues with sub-directories created by other users: as ...
user avatar
0 votes
1 answer
39 views

Using Find Command To Remove Old Backups

I have been using this command to remove old backups on my server: find /backups/etcbak/ -mtime +7 -exec rm {} \; && find /backups/varlogsbak/ -mtime +2 -exec rm {} \; && find /backups/...
user avatar
0 votes
0 answers
29 views

estimate time for find command

I am trying to find some file in my Linux machine using find . -type f -iname *.locked > /tmp/output.txt & and storing them in to the output.txt file. but the thing I want to know is how much ...
user avatar
0 votes
0 answers
55 views

"find" command gets killed when trying to work on thousands of files

I am trying to create PBF out of thousands of OSC changeset files using osmium tool. I have written a Bash script for doing this task using Jenkins. I am merging all OSC files into one master OSC ...
user avatar
1 vote
1 answer
55 views

Creating a file based on output from a find -exec

I'm writing a shell script to batch validate (w3c validator) a load of HTML files. I'm using https://github.com/mozilla/html5-lint which provides a python script to do the actual validation work. The ...
user avatar
  • 113
19 votes
1 answer
887 views

'find -exec mv' misses 4 files

I wanted to move about 1000 mp3 files from a directory called 'music' containing a complicated nested directory structure, to a single directory called 'mp3s', so that I could listen to them in my car....
user avatar
  • 3,593
0 votes
1 answer
61 views

Ansible find files only if contains particular string

I need a small help in writing an ansible playbook. I have written the below till now which is listing all files with config basically. but I need to filter out the files which are basically .git/...
user avatar
2 votes
1 answer
56 views

Is it POSIX compliant for find -exec /no/such/file {} \; to exit with an error?

I am the author of a find replacement which attempts to be compatible with POSIX (and with many popular extensions). Recently I noticed a discrepancy between the behaviour of my utility and other ...
user avatar
0 votes
2 answers
62 views

Find command not working in for loop

I have list of filename , I want to provide those files one by one to find command so that i can get the path. I have use the for loop and take all filename in variable using cat command, Then pass ...
user avatar
  • 11
0 votes
0 answers
38 views

Using bash scripting to search for file on another server using wild cards

What am I doing wrong here. I am not very experienced in bash but trying. In summary, I am trying to ssh from one box(management), and find in a file named "Debug-EmapiTagwireConnector-Wire-2022-...
user avatar
1 vote
1 answer
38 views

Using move command to move all files and subdirectories with find

I have a folder /home/storage/aggregate_data with many sub-folders which in turn contain many files and sub-folders. I want to copy all the files older than 90 days within the folder /home/storage/...
user avatar
0 votes
1 answer
35 views

How to combine find and cp in linux to copy specific files

I am having the following problem in linux: I need to find specific files from a directory and copy those files (if they exist) into another directory this is the command (i need to find specific text ...
user avatar
  • 3
1 vote
1 answer
79 views

How to use find and sed to replace certain sentences in files

I am using find and sed commands to find and replaces the occurrences of certain sentences in the whole directory with some other sentences. For example if I want to replace all occurrences of the ...
user avatar
  • 171
2 votes
2 answers
164 views

Looping through 'find' files and 'grep' to file character set result (standard input)

I'm using find to analyze a list of files. I want it to identify the files that are not ASCII files. So this is what I've tried on the command line: for me in `find 2022*`; do file -i $me | grep -L '...
user avatar
3 votes
2 answers
339 views

Filtering find results by length

I want to find all subdirectories inside a single directory. I need to filter by the name length. I have come up with the following: find ./directory -maxdepth 1 -type d How do I filter the results ...
user avatar
0 votes
3 answers
163 views

Find number of lines between a pattern inside specific filetype

I have a notes.json file inside each directory. The following command counts length of each notes.json file and returns a sorted output by each file's number of lines. find . -name notes.json | xargs ...
user avatar
  • 7
2 votes
2 answers
262 views

find files matching pattern inside directory matching another pattern

Before I resort to writing Python to do this - there must be a way in bash with find or similar tools. I want to search a tree, and find all files whose name matches a pattern, that are in a ...
user avatar
0 votes
1 answer
67 views

`find` command doesn't return array like element, how to work around this

In powershell I'm used to doing something like this: > $python_files = get-childitem *.py > echo $python_files[0] The second command allows me to extract the first file, since get-childitem ...
user avatar
  • 101
0 votes
2 answers
66 views

xargs running more than one command?

Is it possible to use xargs to run more than one command? The only related information I found was this question, but the answer was not related to xargs. I'm running a simple du / -ah | sort -r -n | ...
user avatar
1 vote
2 answers
88 views

How to search filenames by regex with "find" and rename this files

I trying to find all files ending with : ancestors-the-humankind-odyssey-trailers-720-1262.mp4 high-tech-divers-1080-1234.mp4 amazon-divers-720-1323.mp4 and rename this files like this : 720-1262....
user avatar
1 vote
1 answer
60 views

How can I use `find` to find the files and awk to search within the files?

In a folder and its subfolders, I want to search a pattern. For this I am using: grep+cut+awk+tr pipeline. printf "I am so wide alper world zorro the end\t\t\talper\n" > alper.txt ...
user avatar
  • 229
0 votes
2 answers
56 views

Piping find to xargs works in terminal, but not in shell script [duplicate]

I'm trying to write a Bash shell script that copies all the files in the current directory, minus a few exceptions, into another directory. The script builds a command, stores it in a variable, and ...
user avatar
  • 101
0 votes
0 answers
51 views

find: unrecognized: -ctime (radial/busyboxplus:curl)

In a docker container running in a kubernetes pod I am using the below busybox docker image: containers: - name: busyboxplus image: radial/busyboxplus:curl I need to run something like this: ...
user avatar
  • 881
0 votes
1 answer
65 views

Deleting files using xargs prints lots of No such file or directory (but seems to work...)

I have a script that deletes files older than N minutes. The script basically runs: find /some-folder/* -mmin +59 | xargs rm -rf But for some reason it prints tons of: No such file or directory but ...
user avatar
  • 881
0 votes
0 answers
17 views

Debugging find query with -mtime

For some reason reason find command with -mtime option is not working for us. We have files that meet the mtime criterion specified but find is not giving any hits. First of all here are all the ...
user avatar
  • 137
0 votes
0 answers
17 views

find command with exec: are there differences between \; and + [duplicate]

I am looking at a crontab and there is an entry like: 0 * * * * find /path/to/file -type f -mtime +1 -exec rm {} + >/dev/null 2>&1 Now personally I would have used \; instead of + Are the ...
user avatar
  • 137
3 votes
1 answer
170 views

Handle names with spaces when iterating recursively over files [duplicate]

I am trying to recursively convert all .mkv files in a folder structure with subfolders to .mp4. I got a standard line that works in just the present folder for video in *.mkv; do ffmpeg -i "$...
user avatar
  • 135
0 votes
0 answers
21 views

find command behaving abnormally on rhel7 host

find command seems to be behaving abnormally when used with -user option find /var/tmp -type f -user `whoami` -name * or find /var/tmp -type f -user udunto -name * when used , prints file from root ...
user avatar
  • 89
0 votes
1 answer
59 views

How to remember, which order grep and find takes the parameters?

Every time I use grep and find I'm stumbling through, which order I should type the commands: When I should write the path and when I should write the flags, if it needs double quotations or not, etc. ...
user avatar
  • 145
1 vote
2 answers
45 views

How do I handle strange path characters when piping find output?

I had a problem where I wanted to find the length of each path from a find command. My first attempt was to run something like this: find . -exec sh -c "echo {} | wc -c" \; I got this idea ...
user avatar
0 votes
1 answer
26 views

How to display the paths to all files that have a size greater than the specified limit

I need to output the paths to all files that have a size greater than the specified limit (declared as a variable). I've done it using find script: FILESIZE = "+10M"; find "$1" -...
user avatar
  • 39
0 votes
0 answers
19 views

awk or sed - find and replace in multiple files according to a key [duplicate]

I have hundreds of files in which I need to make various replacements - and those replacements are not the same in all of the files. For example, I want to replace: WinEventLog with Windows SysMon ...
user avatar
0 votes
1 answer
42 views

A printf format for "find" or a means to control diff in comparing files across file systems

Working from home, the contents of my laptop undergoes a lot of changes. Before lockdown, I was usually in the office, and I could manually mirror files to a network drive. Working from home means no ...
user avatar
-1 votes
1 answer
20 views

xargs -I# showing unexpected behavior - why?

I'd like to zip a whole bunch of folders which are in a certain directory, creating one zip file per folder. To do that, I use the following command: $ find -maxdepth 1 -mindepth 1 -type d | xargs -I@ ...
user avatar
  • 2,213
0 votes
1 answer
33 views

Script for copy bookmarks from one pdf to another

I want to transfer bookmarks from a series of uncompressed pdf files to their compressed copies (these copies do not have the original bookmarks). I know how to do this one by one using pdftk. First I ...
user avatar
  • 218
0 votes
0 answers
28 views

why does find alter matching behaviour when -exec is appended here? [duplicate]

Consider the following: /tmp/tmp.DkL0R4v7RR$ find . -regex '\./spam' -o -regex '\./eggs' ./spam ./eggs /tmp/tmp.DkL0R4v7RR$ find . -regex '\./spam' -o -regex '\./eggs' -exec ls \{} \; ./eggs /tmp/tmp....
user avatar
  • 753
0 votes
1 answer
48 views

Command substitution with xargs inputs [duplicate]

I'm trying to write a simple command that will create symlinks for all files in a specific directory (Yes, exactly like lndir but I cannot use it so I try to mimic it). I tried the following using ...
user avatar
0 votes
0 answers
23 views

Linux Bash how to find only xdev links

How can I just find paths (linux find command or another) which are omitted by -xdev option. Meaning looking for a command/script fpr finding links which are pointing to paths on other devices and for ...
user avatar
  • 1
3 votes
1 answer
691 views

Linux Bible 10th Edition: why -exec cp can't copy files even with super user privileges?

I read "Linux Bible 10th Edition" at 130 page. Exercise №7: Create a /tmp/FILES directory. Find all files under the /usr/share directory that are more than 5MB and less than 10MB and copy ...
user avatar
  • 135
0 votes
1 answer
17 views

how to "execute command on file in multiple subdirectories within containing folder" i.e cd into each subdirectory containing file and execute command

I have a file named filename.sh in different directories. I am trying to simultaneously submit this file to run on a number of cluster nodes. I need to find this file wherever they may be, cd into ...
user avatar
0 votes
0 answers
41 views

Error "File System Loop Detected" Permission Denied to Decrypt folder with ecryptfs-recover-private

I'm trying to open encrypted files from a full encrypted drive that is unlocked and mounted. I have tried various commands and have been unsuccessful. How can we fix the find "file system loop ...
user avatar
  • 13
0 votes
1 answer
26 views

Find with optional parenthesised arguments

How to add optional grouped argument lists to find? For example, using an array of base arguments that define files that will always be found, no matter what other variable conditions are specified. # ...
user avatar
  • 149

1
2 3 4 5
66