Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [find]

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

1
vote
1answer
32 views

Use pv with find -exec

I use the following command to verify ~700 GiB of backed-up files: $ find -type f -exec md5sum {} + | sort > ~/checksums This takes many hours, so I would like to integrate pv into the command to ...
1
vote
2answers
59 views

Find and copy with exec not working

I'm using the following command to get the most recent file in a directory /usr/bin/find /home/user1/folder1/ -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" " | cut -f5 -d"/" This ...
2
votes
4answers
42 views

Question about behaviour of find

I have trouble deciphering the man page of find and especially the part that states the order of evaluation of logical operators that link the tests. The man page says: OPERATORS Listed in ...
1
vote
1answer
13 views

Everytime I press Crtl+f Xterm opens despite not being a global keybind; how can I disable this behaviour?

I think some programs use xterm so I don't want to uninstall it, but I use bash and Konsole for my terminal, so I don't need it bound to a key, especially Ctrl+f as it makes performing searches ...
0
votes
1answer
24 views

find and move files without overwriting and with output

I'm trying to find and move some files from /home/user/fol1 to /home/user/fol2. Generally I would use find . -type f -name "abc*" -exec mv -t "/path/to/foo/bar" {} + but this overwrites files with ...
0
votes
1answer
21 views

find command fails in jenkins, but not in terminal

I want to export all frames from a lot of video files, automatically in a jenkins build job using ffmpeg. This script is running fine when I ssh into the slave and execute it in the same folder: ...
2
votes
4answers
67 views

Listing files recursively, grouping by user and summing its size

I need to verify the size occupied by each user on my Linux server (all files recursively inside my data folder). With the code below I can get all of my files and their users, but I don't know how ...
3
votes
2answers
162 views

Command: find and delete log files - deep explanation

find $LOG_PATH -type f -mtime +60 -print -exec rm {} \; Above command deletes log files, I did read the manual for each command but didn't understand it WELL. Can anyone explain this in a simple ...
1
vote
2answers
37 views

Error while trying to compress pdf using ghostscript recursively via loop

I intend to compress a few thousand PDF files in a folder recursively. I tried with following loop: #!/bin/bash find "/home/user/original" -type f -name *.pdf | while read -r file do gs -sDEVICE=...
2
votes
1answer
52 views

Prepend line that contains {} in files recursively using find and sed

I want to prepend recursively all files ending with .ts with this text: export {}; and I need to exclude at least the folder node_modules. I tried: find . f ! -path '*/node_modules/*' -iname "*.ts" -...
1
vote
4answers
82 views

sed find and replace html tag

I need find and replace in a md file (plain text) <span class="symbol">&#58771;</span> with this: [&#58771;]{custom-style="symbol"} I tried many times, f.e. sed -i -e 's/\(&...
2
votes
1answer
198 views

Find file by size is not working?

I have a file with size 6284, # ll 1.jpg -rw-r--r-- 1 root root 6284 Jan 10 19:02 1.jpg When I do find . -size 6284 or find . -size 6284b, it shows nothing. Did I miss something?
3
votes
1answer
62 views

Commands Differences Using Quotations (Find)

I was reading the man page of find and I found myself confused with the following commands. What is the difference between one and its corresponding one. What is the difference between the following ...
2
votes
1answer
35 views

Improving performance of Script Using find and exec [closed]

I have a script that iterates through a given directory and automatically compresses those that do not contain at least one file used in less than 30 days. Now, I am wondering if I could improve ...
1
vote
2answers
24 views

Delete non empty directory using find

I'm trying sudo find . -type d -name '__pycache__' -delete as found here https://github.com/python-mode/python-mode#how-to-install on the trouble shooting page of python-mode. The terminal returns: ...
0
votes
1answer
38 views

Find, grep and then create table

I am trying to find all *.md at ${PWD}, then grep for lines beginning with title: and print it along with the absolute filepath -H and the line number of the pattern match -n, then I try to output the ...
0
votes
2answers
26 views

Renaming part of name of all files in a directory tree if match

I have a directory tree like this . |-- players | |-- red_alice.plr | |-- red_bob.plr |-- resources | |-- red_cash.rsc | |-- red_food.rsc I want to go through all directories and rename any ...
2
votes
1answer
37 views

Find a filename in a directory excluding zeros that appear in the beginning of the filename

I have a directory with file names as " 202.png, 405.png, 0052.png, 04050.png, ...... I need a find command to find filenames excluding zeros that appear in the beginning of the file name. For example ...
1
vote
1answer
38 views

Checking the number of files in a specific folder

I have 100 folders (called "Folder_1", "Folder_2", "Folder_3", ...) containing several files. From a loop over each folder, I would like to run commands (i.e., display the folder name) depending on ...
0
votes
2answers
51 views

how to delete files in folder with thousands of files [duplicate]

in the folder cd /var/log/hive I guess we have thundered of log files I say that because if I do under this folder ls -l then its stuck and only CNTRL C , will exit so I cant to vew all ...
11
votes
2answers
916 views

Use chmod command selectively

I want to set 755 permission on all files and sub-directories under a specific directory, but I want to execute chmod 755 only for those components which does not have 755 permission. find /...
1
vote
1answer
50 views

Testing if two directory trees overlap

Let $foo and $bar be two absolute directory names (output by realpath). I want to test if either is contained in the other one, at any depth, and execute commands accordingly. I thought I'd use find, ...
3
votes
1answer
52 views

Why is find(ing) by -atime not printing expected files? [closed]

I'm trying to recursively find files that have not been accessed for over 365 days. I can use stat and verify that the file has not been accessed for over 365 days. It is odd that the file shows that ...
2
votes
1answer
19 views

WildCard Find Replace CP

I'm trying to replace files that match a particular pattern* on CentOS, but it is not working. I initially wrote: cp example.com/(*)/orm-mysql/build/conf/(*)-conf.live.php example_dev.com/$1/orm-...
0
votes
1answer
71 views

awk is not working for my requirement [duplicate]

My requirement is that shell script should print the folder name of the file. For example comp.class is present in D:/Practice/HelloWorldPractice/bin folder, I should get output after executing ...
2
votes
1answer
40 views

How does find prevent endless loops (e.g. when renaming files while finding them)? [duplicate]

Please consider the following command: find . -type f -name '*.*' -exec mv '{}' '{}_foo' \; How does find prevent endless loops in this case? On one hand, I believe to know that find does not work ...
2
votes
1answer
61 views

Why should I escape the semicolon with find?

I'm using bash on Debian. I have to write find -iname "*mp3" -exec cp {} /media/MP3Player/ \; escaping the final semicolon, or else I get an error.
1
vote
1answer
43 views

move files of certain type and rename ones with the same name

Here is what I am trying to achieve: I converted pst files using readpst library into separate .eml files. After converting each of the pst files, I got a directory with multiple sub-directories ...
10
votes
4answers
1k views

Move all files NOT ending with .txt [duplicate]

In the directory /home/username/data I have both files and directories. Some of these filenames end in .txt (to which I'll refer as text files), others don't. The same happens in the subdirectories. ...
4
votes
2answers
338 views

chown: missing operand after ‘root:users’

I try to change owner to root:users recursively below a directory, if owner is other than root:users. cd /dir/ find . \( ! -user root -o ! -group users \) -print0 | xargs -0 chown -vc root:users I ...
-1
votes
1answer
41 views

find the relevant files with their checksum

We want to find all the .jar files with their chksum. find . -name "*.jar" ./lib/ant-1.8.0.jar ./lib/ant-launcher-1.8.0.jar ./lib/backport-util-concurrent-3.1.jar ./lib/classworlds-1.1-alpha-2.jar ./...
-2
votes
1answer
53 views

Show only lines which contain numbers [closed]

I have a file with the following lines: irakli1 iraklikairakli ikarkalsi1 iarksldisrii3 irakli and I want to show only the lines which contain numbers. I tried this but it is not working: sed -n '/...
0
votes
2answers
23 views

Save in a file first 7 file in the directory /bin that starts with c

I have write a command in the shell of linux to count the file (in total 8) starting with 'c'in the directory /bin find /bin/[c]* -type f | wc -l What I wish to do now, it's save the name of the ...
1
vote
1answer
31 views

Locating font files

There's a utility called fc-list in the fontconfig library, that's good for listing installed fonts. It detected a few hundred system fonts. I ended up using find to locate all files with common ...
-1
votes
1answer
20 views

Why does adding -prune to my sync script cause rsync to do a DRY-RUN?

I'm testing a script to do a by-directional sync of two directories intelligently using rsync. Since I'm testing many of the rsync options are not applicable to the testing environment including the ...
-1
votes
1answer
37 views

grep -v is not excluding the strings [duplicate]

im trying to narrow down a flag to catch by removing strings with certain unwanted words so i use cat $(find / -size 33c -group bandit6 -user bandit7) | grep -v 'Permission' but my results end up ...
0
votes
4answers
91 views

how to echo find command

For a raspberry backup bash-script I want to log which and how many older backups are deleted. I use find $backup_path/$HOSTNAME.*.img -mtime +$retention_days -type f -delete to clean. How do I ...
-3
votes
1answer
57 views

Why I have no permission ? [closed]

So I execute the find command in the picture, why there are so many permission denied? I am a root user. Just this problem.
0
votes
0answers
50 views

How to exclude a directory or partition on pmlogger scan?

As on the details below it look like that the cause of the problem is the pmlogger is spawning the find command. And its takes a long time for the find to scan all the files in one of my partition. ...
-1
votes
0answers
62 views

bash: find exec in a subshell with multiple commands

I am using find and then executing a set of commands in a subshell as follows: find ${CWD} -name "Sourced.sh" -exec bash -c '\ i="$1"; echo ${i}; \ cat ${i} > ${i}.temp; \ "${dScriptP}"/Substitute....
-1
votes
1answer
66 views

find: paths must precede expression

I ran this command: find /home/ ~ -type f -size 5 "*." -a -30 but it said find: paths must precede expression.  I am having a hard time getting find to look for matches in the current directory as ...
0
votes
0answers
43 views

problem with find xargs and tar concatenation

I want to store all the png files in a directory tree. I used find . -iname *.png| xargs tar -czf renderresultsall.tar.gz but I get only a part of the files, some directories are missing e.g. ....
3
votes
1answer
135 views

Why is find piping in non directories when the “-type d” test is used?

I have a directory ~/root/ |-- bar |-- eggs |-- foo |-- hello.txt |-- script.sh `-- spam 4 directories, 2 files Issuing find . -type d while in ~/root/ yields . ./spam ./eggs ./bar ./foo However, ...
-1
votes
1answer
21 views

find command sends subfolders even with maxdepth having value of 2?

I have this bash command: find . -type d -mindepth 1 -maxdepth 2 | du -h --threshold=2KB and I got these results: r2g: the tarball folders: 8.0K ./cli r2g: the tarball folders: 24K ./dist/...
0
votes
2answers
41 views

Find files (not) containing text pattern on a specified line

I'm trying to search through a set of text files and return the names of files that on a specified line contain a text pattern OR do not contain the text on the specified. In my case I need to return ...
1
vote
2answers
32 views

Using find, how to classify like ls -F ? (directories with a trailing slash)

I use find to get a list of files, then I grep it to do a path matching : $ find pc* | grep -i arthur pc6/arthurv/untitled-2.py pc6/arthurv/untitled-3.py pc6/arthur.py pc9/Arthur 4C pc9/Arthur 4C/...
1
vote
0answers
18 views

Renaming many files to their parent directory name [duplicate]

I want to recursively change many files named raw.tex to parent-directory-hw.tex. Is there a simple scripting solution to this problem? For example, running the script on . `-- root |-- baz |...
0
votes
3answers
47 views

Using find to list directories that haven't been accessed since a certain date?

Using the stat command one can see and format the last date a directory was accessed. The adate Is it possible to use find to find the directories that were changed before a certain date using a ...
3
votes
1answer
76 views

find not working correctly in cron

We have a regular job on a server that creates some files in /tmp and doesn't delete them after it is done. For reasons I don't want to get into, we can't modify the job to delete the files. So I was ...
0
votes
1answer
40 views

remove only empty folders with empty flag - is it safe

we create the following command in order to remove only the empty folders that older then 100min find /tmp -type d -empty -mmin +100 -printf '%p was deleted!!\n' -delete because we intend to run it ...