Questions tagged [find]

find is a command line utility to search for files in a directory hierarchy

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

Remove files with 000 permissions in current directory

I am trying to remove the files with begins with pattern sed*. Filename length should be equal to nine and also it should have chmod permissions as 000 from the current directory in Linux. But couldn'...
0
votes
2answers
28 views

Last modify files in folder

In a folder I have files with nanoseconds timestamps.: FileLastestFile.ext FileOther0.ext FileOther1.ext FileOther2.ext FileOther3.ext FileOther4.ext ... FileOther.ext I want to keep only file that ...
1
vote
1answer
27 views

how to change value of parameter recursive under folder

under /etc/sysconfig/network-scripts , we have network configuration files as ifcfg-conf1 ifcfg-conf2 . . . is it possible to change all parameters - PEERDNS to no , if value is yes expected ...
0
votes
1answer
44 views

Why does find and exec mv not move all files?

The current working directory has multiple test files numbered between 1 to 100. These are titled 1.txt through to 100.txt. The command find . -maxdepth 1 -regextype posix-egrep -regex '.*/[ -._&...
0
votes
1answer
29 views

quickly change permissions of all directories in $HOME while skipping all mounts

In the case where the user home directory contains one or more NFS mount points, how can I skip these mounts and efficiently change directory permissions? I want to run chmod o-rwx on all non-mounted ...
0
votes
1answer
22 views

Rsync with specific day condition in respective subdirectories

I have two identical folders with subfolders for development and live like: /development/subdirectory1 /development/subdirectory1/subsub1 /development/subdirectory2 /development/subdirectory2/subsub2 ...
0
votes
2answers
28 views

What does this part mean in find command with -exec \{\}? [duplicate]

I have this command (KSH) find <path> -regextype posix-extended -type f -regex '.*/txt' -exec ls -l --full-time \{\} \; | sort -bnr So, I'm reading and deciphering the command above so far ...
0
votes
2answers
61 views

Find files between two times/hours using find

I will write some context for my problem. I have to deal with a process that runs everyday that creates files in three secuential steps: A, B and C. Files from steps A and C are stored in one folder (...
0
votes
1answer
32 views

Rename a file with find without knowing the directory

I need to find a file, lets say passfail.txt in a subdirectory of X which contains random generated directories (X/randomDir/passfail.txt). I want to rename that file to passfail_SOMESTRING.txt while ...
0
votes
2answers
31 views

Rename recursively exluding the current directory

I use this command to rename files recursively: find -iname \*.bak | rename 's/.bak/.old/' But I want to exclude the current directory. Example: .bak dir1/.bak dir2/.bak ... After I want this: ....
0
votes
1answer
10 views

How to output last match in multiple files in subdirectories and output the file path with each match

I've managed to find the last match in multiple files in multiple subdirectories, but I wish to also output the file path and cannot manage to. How can I change find subdirprefix* -name log -exec sh -...
0
votes
2answers
29 views

How do I grep out of every tar archive on a system using 'find' and -exec 'tar'?

The command I'm trying (as I'm trying to find tars with 'butterflyinmotion.com' as a dir in them) is: find / -name "*.tar.gz" -exec tar -tzf {} \; | grep -W butterflyinmotion This shows a lot of ...
-1
votes
1answer
60 views

find + delete files bigger than 2G and when there's less than X available space

How can I delete files called stdout / stderr that are located under the /data/sdf mount point, according to the following rules? The available disk space (on /dev/sdf) is less than 100G The stdout ...
0
votes
1answer
55 views

Recursively search directories for a filename, stop descending if found

I have a directory-tree which contains files with the same name, e.g.: a/file a/... a/b/file x/a/file x/a/... x/b/file I'm trying to use find (with -exec and -prune) to get all paths where file ...
0
votes
2answers
26 views

How do I pipe the results of a “find” or “ls” to a file AFTER it has completed its stdout?

So for some reason when I do something like find $PWD -type f > listoffiles.txt To create a list of files in current directory and save it to a list, The file "listoffiles.txt" itself is somehow ...
2
votes
0answers
79 views

Portable way of finding files whose birth date is after a given timestamp

According to How to find creation date of file?, in Linux filesystems, such as ext4, Btrfs and JFS, that store the file creation time (aka birth time), it is possible to display the file birth time (...
2
votes
1answer
39 views

Search directories containing numbers larger than a certain threshold in their name

This is the command that I have and would like to modify with an additional condition: find /home/user/backups/ -mindepth 2 -maxdepth 3 -name "*~EEEE000.tif" -print This is the output of ls /home/...
0
votes
2answers
76 views

recursively find *.c files for dos2unix processing

The goal is to find *.c files to be processed with dos2unix: find . -name *.c | xargs dos2unix -f In an attempt to troubleshoot the above command: user@host:~/csim/exercise$ find . -name *.c ./6-1/...
0
votes
3answers
93 views

Linux can't apply “find” in a pipe

I am searching for a file in the directory tree below me. When I try find . -name xyz, I get screenfuls of find: '/home/fred' : Permission denied That makes sense as I don't have access rights to ...
-1
votes
0answers
46 views

How to remove files which either don't contain a string, or can't be opened?

Simplified text file version of the problem Consider a directory of text files. How can I output the filenames of and lines in the text files which contain the string, remove pdf files which don'...
0
votes
1answer
43 views

Find-based mv renaming fails in a shellscript

I wanted to do a simple script to rename files, well parts of files. While the command works just fine from commandline: find . -type f -name "*old*" -exec bash -c 'mv "$0" "${0/old/new}"' {} \; 2>...
1
vote
1answer
25 views

Recursive thumbnail creation to different destination

I wish to show my photo collection on my television. In order to do this, I need to resize the photos to fit in a 1920x1080px window (because the performance is awful when dealing with the originals). ...
0
votes
0answers
21 views

GNU `find` issue : `find -name` isn't recursive when pattern is found in current directory [duplicate]

I have a test tree that goes like this : user@host :~/test/ $ tree . └── 1st ├── 1st.json └── 2nd ├── 2nd.json └── 3rd └── 4th ├── 4th.json ...
0
votes
3answers
114 views

How do I tar all files without paths

I want to find all .c files in current directory and subdirectories and tar them. I try to use the following way to achieve this goal but when i unzip files, the files in different folders. I don't ...
0
votes
0answers
21 views

find and copy command: what if the file is already present or copied few minutes back?

I have a job that triggers the script, the job always runs in the background nohup copy_files.sh & In the shell script, I am running following code indefinitely using while(true) loop find . -...
1
vote
1answer
21 views

How to find a file and copy its directory?

I use the following command to find a file and copy it somewhere else, find /search/ -name file.txt -exec cp -Rp {} /destination \; How can I copy all files and subdirectories in the parent ...
2
votes
2answers
108 views

Script to recursively replace invalid characters in filenames, not directories, with rename

I'm looking to write a script that will find and replace any characters other than [^A-Za-z0-9._-] in a specific file type (in this case .avi) with an underscore _. I want this to exec recursively ...
-2
votes
1answer
42 views

How to get dirname from path

I have this: find . -type f -name '*_test.go' | xargs dirname but I get: usage: dirname path the output of $ find . -type f -name '*_test.go' is: ./pkg_test.go ./v3/organization/...
0
votes
2answers
56 views

Script in Bash: Find all files

I want to write a script in Bash which finds all files less than 100b in /etc directory, splits the results on pages and saves the results to a file. I tried to use this command: find /etc -size -...
1
vote
2answers
64 views

Using a regular expression with zip command for directory exclusions

I am trying to zip up my application and would like to exclude all of my image directories apart from one. Consider the following folder structure: /images │ └───/foo // exclude │ └───/bar // ...
0
votes
0answers
54 views

How to find files with the SUID bit set?

I am interested in finding all the files in the system that has the SUID bit set. The find / -perm 4755 command finds files that have the SUID bit set but with the permission of 755. But is there a ...
0
votes
2answers
34 views

Find command output doesn't give desire result

Create files touch a1.txt a2.txt a3.txt touch s1.mp3 s2.mp3 s3.mp3 then I do find . -name "*.txt" -or -type f -print And it's showing only s1.mp3 s2.mp3 s3.mp3. Why it's not showing .txt files?
-1
votes
2answers
61 views

Why does xargs output results with new line characters?

When executing the command find . -maxdepth 1 -regextype posix-egrep -regex '.*/[a-zA-Z]+\.txt, it returns the following results. ./testfile.txt ./testread.txt In contrast the the command find . -...
2
votes
6answers
345 views

How could I improve this script which sorts files according to extension?

I have a small script which simply shall go through my Downloads folder and then sort the files according to the extension. How can I make this cleaner/better? I would like to simply maintain a list ...
0
votes
0answers
38 views

Find and print permissions command in a csh file

Trying to create a .csh file that can find and display permission of the files in the directory. Using the following content of the script #!/bin/csh -b find . type -f \( -name "*.sh" -o -name "*....
3
votes
3answers
734 views

new decade: how to utter something like `find /path/ -name 'file.20{19,20}*'` (but which works)

summary: A given system has lots text files with names ~= [type of file].[8-digit date]. To search these files, I like (and wanna keep) using this idiom: find /path/ -name 'file.nnnn*' -print | xargs ...
-2
votes
2answers
67 views

find + delete files with date format

we have the following logs /var/log/sync/manager.log.2018-06-14-00 /var/log/sync/manager.log.2020-01-14-07 /var/log/sync/manager.log.2020-01-14-02 /var/log/sync/manager.log.2020-01-14-03 /var/log/...
0
votes
0answers
49 views

Adding a prefix to output from find and exec

I need to run a command on multiple files. The output should be cor_FILENAME and cov_FILENAME and hence I have the following: find . -name "*.tsv" -exec fastspar --otu_table {} --correlation ...
1
vote
1answer
23 views

tar only those folders listed in a file

Here is my problem the directory structure is /home/user/backup/name1/date1/name1-date1.cfg /home/user/backup/name1/date2/name1-date2.cfg /home/user/backup/name2/date1/name2-date1.cfg /home/user/...
0
votes
0answers
31 views

move files up a dir for every dir in parent

My TV library folder for PMS has gotten worse and worse. To an extent it is cleaned up now, but a good bit still needs to be done. Got the commands for finding and deleting .nfo/.txt/.../empty dirs (...
0
votes
1answer
51 views

Confusion with Linux find regex

I'm getting quite confused with Linux find command's regular expression usage. I'm aware that there is an option regextype, but without that, according to the current man page, it is supposed to use ...
-1
votes
1answer
32 views

Find command returns no such file message for an unrelated file

My command seems to run fine. However, sometimes, it returns a message about an unrelated file not present. The directory being searched has a lot of activity and files are being created and deleted ...
17
votes
1answer
2k views

How can I change a file to a directory? Files lost after find+mv

I had a directory containing some 2000 files. I ran the following command to move those 2000 files into a target directory: find /opt/alfresco \ -type f \( -iname \*.pdf -o -iname \*.xml \) \ ...
0
votes
3answers
80 views

Run find on find

I did a web seach for "linux run find on find" but it produced no relevant results. I want to build list of files by find and then run find again on that list. After fixing some "silly" mistakes I ...
0
votes
0answers
30 views

How to redirect a sorted list of files returned by GNU find to a GUI file manager such as Nautilus or Dolphin

Question I often fall in this situation where I have meticulously forged the perfect find command that returns exactly the ordered list of files I need to use. However, I cannot simply click on files ...
2
votes
1answer
63 views

Single quote problem in “sh -c” script launched from “find”

Now I am writing a script for a long time, but lately this problem has drives me crazy. I tried everything but couldn't solve it. find . -iname "*.mp4" -type f -exec ffmpeg -i "{}" -c:a "$ACODEC" -c:...
0
votes
1answer
42 views

Remove specific file if it hasn't been modified for 1 day

I want to delete the specific file, std_info under /tmp, if it hasn't been modified within a day (or 1440 minutes). For now, I created the following syntax that prints only the files that were ...
4
votes
2answers
996 views

Why is the hyphen symbol - not discoverable in a regular expression in the find command?

To identify files with the hyphen symbol - in file names such as test-19.1.txt, the find command combined with a regular expression does not appear to match. The command find . -maxdepth 1 -...
0
votes
1answer
23 views

How do I remove a line containing word in multiple files?

I want to remove a line that contains <premiered> in *.nfo files including subdirectories. This is the command that I use find . -type f -name '*.nfo' -exec sh -c ' file="$0" echo "$file" ...
0
votes
3answers
47 views

using find or other command to restrict the search of a file name extension within the same directory

I have a directory which has multiple subdirectories in it. I am looping through the subdirectories one by one. Then I change the directory using cd. If in that sub directory, I have a file having an ...

1 2 3 4 5 54