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
3
votes
1answer
58 views

Count lines in csv files nested in subdir using find exec

I'd like to run two piped commands on the results of find on some nested csv files, but I miserably fail. Here is the idea: $ find ./tmp/*/ -name '*.csv' -exec tail -n +2 {} | wc -l \; in order not ...
0
votes
1answer
15 views

rsyncing with --files-from and -mtime option downloading old files that are in a newer directory

I've got the following command to try to sync only files less than about 36 hours old (2200 minutes): sudo su -c "rsync -vrt --delete --rsync-path='sudo rsync' --files-from=<(find '/home/dir1' ...
0
votes
2answers
35 views

Storing array as Environment variable to noninteractive shell with xargs

This is in continuation of Storing array as Environment variable to non-interactive shell - Unix & Linux Stack Exchange. Kusalananda, asked me to ask another question. I want to find all markdown ...
2
votes
2answers
196 views

Find all executable files excluding certain directories

I'm looking to find all executable files that are NOT in my $PATH. Currently I'm doing this find / \( -path "/opt" -prune -o -path "/var" -prune -o -path "/bin" -prune -o ...
1
vote
1answer
19 views

tar --skip-old-files: Cannot open: No such file or directory

I am trying to uncompress all files in a directory. They are are scattered throughout various sub-directories, so I can't just use wildcards. Instead, I used find: find . -name "*.tar.gz" -...
-1
votes
1answer
35 views

How to change all files in directory creation/modification date to 0/0/0?

I want to change all files in directory creation/modification date to 0/0/0. I tried to use find $PWD -exec touch -m -d '0/0/0' {} + command.
0
votes
1answer
48 views

How to send find -exec to output file with {} [duplicate]

I am trying to find and replace text inside several .sas files using find -exec along with sed, but I would like to direct the output to new .sas files named according to the result of the find ...
1
vote
2answers
31 views

change permissions with find for specific files

Let's say I have a directory called permissions, that contains several files with different access rights. What I want to do is if a file has access rights for others category, I want to accord the ...
-1
votes
1answer
29 views

How can I list all modified files from 2020 on a server?

I need to list all the modified files starting from / recursively. Only the 2020 files. I have tried several commands with find but it does not work.
1
vote
1answer
36 views

Find files in all directories by name in and copy to another directory using rsync

I have listed file names each per line in list.txt like below filename1.pdf file456.pdf file33.txt ....... I want to search by file name in a directory (including all subfolders in source) ...
0
votes
1answer
41 views

find + search huge files in short time

I am using the following find syntax in order to find huge std* files that are more then 1000M. find /data -type f \( -name "stdout" -o -name "stderr" \) -size +1000M -print ...
-1
votes
0answers
30 views

find Returns Inconsistent Results (Bash, MacOS)

If I run find . -iname "*cache*" I get the following: ./HOW-CAN-I-ENSURE-THAT-MY-ADS-ARE-RUNNING/m-p/jquery.ajax-cache-response-1.0.html.tmp ./HOW-CAN-I-ENSURE-THAT-MY-ADS-ARE-RUNNING/m-p/...
0
votes
0answers
23 views

Bash script (triggered on Transmission torrent download) not working

I'm trying to create a bash script that is executed by Transmission when a torrent file is downloaded, and automatically extract *.rar files into the same directory. This is what I have #!/bin/bash ...
0
votes
3answers
60 views

find text in one file and replace with text from another file SED or AWK

Ubuntu 18 build I am trying to find this text, [define( 'AUTH_KEY',] without [] in /var/www/file1.txt, and then copy the line and replace the same line in /var/www/file2.php. I have tried multiple ...
0
votes
3answers
31 views

list only direct child directories of all directories with a particular name

I have a directory structure like the following: . ├── Untitled Folder │   ├── Untitled Folder │   │   └── zing │   │   ├── first | | | └── dum │   │   ├── second │   │   └── ...
0
votes
1answer
75 views

POSIX alternative to GNU find's -print0

GNU find has a -print0 option to terminate filenames with null characters. However, this option is not available in POSIX find. In the GNU man page for find, under the -print flag, it says: If you ...
0
votes
1answer
51 views

How to grep on files less than a size and limit to extension [duplicate]

I want to recursively grep on all files in subdirectories with extension csv but select only those files that are less than 4M in size. Is this correct way to do? find . -type f -size -4M | grep --...
0
votes
1answer
29 views

find & copy command is not copying same number of files

I'm trying to use find & copy on some files but the problem is if i only run find command and check wc it shows some result, after copying these files to some other directories it shows some other ...
2
votes
2answers
265 views

What is `â<80><98>` and how to avoid it?

I do a cd /folder/ && find . -not \( -path ./exclude_folder -prune \) > /log.log and get find: â<80><98>./qs/www/ergebnisse/validitaet/0df21b8a-e227-47b2-aaa5-9f54d1f9b8fd.txtâ&...
0
votes
1answer
77 views

Find recursively all files whose content match a specific regular expression

I like to search all PHP files and find a particular string that is identified by a regular expression. The regular expressions that I use to find the string is: \$[a-zA-Z0-9]{5,8}\s\=\s.{30,50}\;\$[a-...
1
vote
1answer
57 views

Alternative to ls | grep [duplicate]

I'm trying to search through the files and directories of a specific folder. For example, I was looking in /usr/bin for my python binaries. To do so, I used ls | grep python. When I did this, I was ...
0
votes
1answer
27 views

rsync: read list of files from pipe

I can transfer file /tmp/file using rsync to remote server: rsync -R -av /tmp/file root@server:/ but how can I provide the list of files to be transfert from a pipe? I tried using the --files-from= ...
0
votes
2answers
30 views

GNU find logical operators with -print

Consider the following file layout: . ├── dir_a │   └── file_1 └── file_2 Invoking find . \( -name dir_a -prune \) -a -print gives ./dir_a but invoking find . \( -name dir_a -prune \) -o -print ...
10
votes
3answers
875 views

Why does find not find my directory neither with -name nor with -regex

I have a directory ~/Documents/machine_learning_coursera/. The command find . -type d -name '^machine' does not find anything I also tried find . -type d -regextype posix-extended -regex '^machine' ...
0
votes
1answer
23 views

how to delete all repo except specific repo files under /etc/yum.repos.d

under /etc/yum/repos.d we have the following repo mng.repo vrtf.repo dbNM.repo sometimes users create other repo under /etc/yum/repos.d and this make mass because yum conflicts so we want to delete ...
1
vote
2answers
28 views

Find zip files in all directories but exclude some folders

I want to see all zip files in /home directory on my server and all users folders too, but I want to exclude the '.composer/' and 'vendor/' folders that may or may not exist on clients directories i ...
0
votes
1answer
19 views

Readable format of file sizes using the Find command

To see human readable output, I can use the following command – du command -h option : Display sizes in human readable format (e.g., 1K, 234M, 2G). $ du -hsx * | sort -rh | head -10 The sample output ...
2
votes
2answers
279 views

Difference between GNU find -not and GNU find -prune -o -print

This answer on opening all files in vim except [condition]: https://unix.stackexchange.com/a/149356/98426 gives an answer similar to this: find . \( -name '.?*' -prune \) -o -type f -print (I adapted ...
0
votes
0answers
34 views

find -cmin vs. find -mmin || status vs. data – What is the difference?

I'm learning the find command and trying out variations .. Wondering what the actual difference is between find ~ -cmin 1 and find ~ -mmin 1. Reading the man page, the difference comes down to file ...
0
votes
1answer
21 views

How to check if /var/some-dir/* returns anything

How to check if /var/some-dir/* returns anything? I use find /var/some-dir/* ... but if the pattern is empty I get an error.. I don't want to redirect stderr I want to check before executing find is ...
1
vote
0answers
24 views

Find directories that don't have a file with specified name [duplicate]

I've done a good amount of research on this and put together this command, but it appears to be finding the directories that HAVE scanned.txt not the directories that don't have scanned.txt. How can I ...
2
votes
1answer
39 views

Find Command excluding multiple directories and multiple file extentions

I have a folder with lots of files and folder. It contains many multimedia files (jpg, jpeg, mp4, mpeg). The directory also contains lots of sub folders. I want to do two things : Find the total ...
0
votes
2answers
110 views

while read line find – faster with perl?

I have a text file with three columns separated by tab and I read the third column line by line to find all files in a directory which have this in the name. Since it is a file with up to 1000 entries,...
4
votes
1answer
66 views

Find PDFs that don't have text

I have many folders with lots of PDFs and I want to Optical Character Recognise those that do not have a text layer. So first, I want to find them. I thought that maybe a pipe with pdfgrep would do ...
4
votes
1answer
41 views

How do I ignore warnings, but keep error messages from 'find'

I'm trying to run a find command, and due to the way the folder is set up, I keep getting the following warnings several times in my script: find -L ./server/ -type f -printf '%s %p\n' | <rest of ...
-1
votes
2answers
32 views

Optimize time when creating archive

Currently I am using the following command to create an archive with files older than 7 days: find /var/tunningLog/ -type f -mtime +7 -print0 | tar -czf "/var/tunningLog/$(date '+%Y-%m-%d').tar....
1
vote
2answers
61 views

find filenames of one extension that don't have a matching filename of a different extenion

I bought a special digital camera that saves a proprietary image format, which ends in .lri. The company has a desktop program to render .lri files into standard jpg and dng files. I'm finding that as ...
1
vote
1answer
34 views

How to count directories that starts with a specific letter?

I'm trying to get a number of directories that start with a specific letter. I tried to get this done with: find /home/test1 -type d | grep -m 1 a* | wc -l but I'm getting 0 in the result no matter ...
0
votes
0answers
27 views

Need Help to use GREP and FIND Combinated to parse a texte file and move files

Here is my goal: I have a list of files name (with .mp3 extension) inside a text file, and I want, launching a small terminal command, to copy the files in my folder (the files that matches names ...
0
votes
0answers
19 views

block size difference in ls -s and find -size

I was trying to find the files in the current directory that are of size 1 block , so first I run the ls -ls command which show the number of blocks of each file and here is the output : total 28 0 -...
2
votes
2answers
66 views

How to use find command to list file names but not path?

I've checked some answers online, but they do not work when there's a -name parameter in the command (maybe I'm doing something wrong, not sure). What I'd like to do is to list only filenames (not the ...
0
votes
1answer
15 views

recursively delete all files+folders except a specific one file in solaris

The below command recursively deletes all but 104.tar file under /tmp/CURRENT folder. find /tmp/CURRENT/ -type f ! -name '104.tar' -exec rm -rf {} + It however, does not recursively delete any sub-...
1
vote
1answer
38 views

How to prevent find traversing certain directories, but still list them?

I have the following folder structure: example/ ├── bar/ │   ├── 1 │   ├── 2 │   ├── 3 │   ├── 4 │   ├── 5.txt │   ├── bar.mylib/ │   │   ├── 1 │   │   ├── 2 │   │   ├── 3 │   │   ├── 4 │   │   ├── 5 │...
4
votes
1answer
89 views

perl `rename` script not working in some cases?

I tried running the following command: find . -type f -exec rename -v 's/ /_/g' {} \; , to rename all files recursively with spaces in their names with underscores. The problem is that it works ...
1
vote
2answers
46 views

How to handle with command to execute only it's subdirectory? [duplicate]

I'm looking for a way of execute command which I can execute some command only under sub directory not command affect to current directory. find -name ":RUN" -exec rm -rf {} \; If I got a ...
0
votes
1answer
67 views

find: ‘zip’: No such file or directory

I'm using WSL (Ubuntu) and trying to recursively zip the files in a bunch of subfolders. i.e. Main Folder . SubFolder 1's files get zipped into a .zip SubFolder 2's files get zipped into a .zip ...
0
votes
1answer
18 views

What would the value of hyphen actually look like in this instance used to refer to stdin for this archive command?

I am following a guide to learn terminal commands and have encountered the use of hyphens to refer to stdin in the following command used to find all files named 'file-A' within the directory ...
4
votes
3answers
763 views

Find -exec dry run?

Is there a way to see what the result of a find . -exec somecommand {} \; would be with substitutions, without actually running the commands? Like a dry run (or test run or print)? For example, ...
1
vote
1answer
43 views

Exclude directories for du command / Index all files in a directory

My goal is rather simple: I want to create a small database of all files/directories within a big directory. After looking for a tool suited I couldn't find anything but the good ol' du. I figured out ...
0
votes
1answer
75 views

How do I copy variously named files with the same extension to all have a standard file name?

I have variously named files such as in different subdirectories e.g.: a/apple.txt b/orange.txt c/pear.txt How do I copy them to have a uniform name (fruit.txt) in their respective directories so the ...

1
2 3 4 5
60