Questions tagged [find]
A commandline utility to find files and directories.
666
questions
0
votes
1
answer
284
views
How to store output of find from a background command
I have the following excerpt from a script for finding certain subfolders. Meanwhile a spinner indicates that something is taking longer in the background:
# runs find as background task and ...
2
votes
1
answer
7k
views
Ubuntu restore deleted files from find -delete [duplicate]
So I just recently downloaded Linux Ubuntu and I was experimenting with some of the functions to get used to Linux.
While I was trying to learn I wrote in the terminal
find . -delete -name (file name)
...
2
votes
1
answer
310
views
How can I find out which file was changed a few minutes ago?
I want to transport a configuration from one user to another one. But I don't know in which file the program in question stores its configuration.
In order to find out where the configuration is ...
0
votes
1
answer
88
views
Bash, get 3 last files detected by first 3 same characters, and move other files
Issue, I have many files in folder backup.
3tpt_20190810_061011816.csv
3tpt_20190811_060912007.csv
3tpt_20190812_060910510.csv
3tpt_20190813_060911075.csv
3tpt_20190814_060911689.csv
...
1
vote
1
answer
133
views
How can I print this to file in bash?
I have no idea what I should do to make it work:
find . -name '*.txt' -printf '\t%s\t%f\n' |sort -n -r | > txt.txt
3
votes
2
answers
5k
views
how to find or list file and directories which having size more than 100mb
How to find or list file directories which having size more than 100 MB
I'm using du -sh* to get the size of file but my system don't have permission
-2
votes
1
answer
148
views
Copy files such that individual files gets copied to the folder having file name as a string within complete folder name [closed]
I am using Cygwin as Linux shell,
I have following contents in my current working directory:
Files :
Abc.dat
123.dat
456.dat
Directories:
W_Abc_w
W_123_w
W_456_w
Now I want to copy files as ...
4
votes
2
answers
3k
views
find files with suffix of org or md [duplicate]
I'd like to find all the files suffix with .md or .org
find ~ -iregex ".*\.md$"
find ~ -iregex ".*\.org$"
How could combine them?
5
votes
3
answers
639
views
Listing files that end in ".txt" from directories with the word "SALARIO" in its name without using pipes
I used:
find . -type d -name "SALARIO*"
to find the directories with that word in the name and then:
find . -type f -name "*.txt"
to find all files that end in txt in those directories.
How do I ...
0
votes
1
answer
816
views
Remove previous directories before cloning in Gitlab CI/CD
I am using Gitlab Runner for deploy new website version into server.
Original scenario of deploying is to shallow clone to new directory with current date time string like "2019-10-27-17-43-05".
then ...
25
votes
1
answer
7k
views
Ubuntu 19.10: why is the "locate" command missing?
OS: Ubuntu 19.10
When I ran locate plymouth, I got
dkb@dkb-uee:~$ locate plymouth
Command 'locate' not found, but can be installed with:
sudo apt install mlocate
dkb@dkb-uee:~$
So I installed ...
1
vote
1
answer
127
views
stat command format to append '/' to file name if directory, and remove "./" from front
With the following command I have been able to list all the directories relative to the current directory along with the epoch time last modified:
find . -exec stat -c '%n: %Y' {} \;
the output ...
2
votes
3
answers
2k
views
cp: cannot stat './1_true/*': No such file or directory, when find directories and copy files
i have many directories like this:
$ ls
1_true 1_false 2_true 2_false 3_true 3_false ...
i want to copy files in "*_true/" to other directory.
when i run command like below
find . -name "*_true"...
-1
votes
2
answers
509
views
how do i move all files from one folder to another in terminal
I have searched various forums with variations on the question -
I am trying to move all files including those in sub folders from one folder to another - just the files not the folders.
This ...
17
votes
3
answers
8k
views
How do I find files with no group permissions?
I just want to know how I can find, in a folder, the files that have no group user permission (no read/write/execute) at all, using the terminal.
5
votes
1
answer
3k
views
Find command with regular expressions
I am practicing a find command and the moment, and am curious about the usage of regular expressions in the find command(similar to grep). Does the command support it? If so, what are the options to ...
4
votes
2
answers
4k
views
find with wildcard path and export the result to a file
I need to find files that match this pattern:
find root_folder/*/match_string/*.ext
"*" means any levels of folders or files. So it means any file with an extention "ext" under root_folder or its ...
15
votes
4
answers
5k
views
Delete empty subfolders, keep parent folder
When I use
find /home/user/parentdir -type d -empty -delete
it looks recursively for empty subfolders inside /home/user/parentdir and deletes them. But if /home/user/parentdir is also empty, it ...
9
votes
1
answer
7k
views
How to use multiple criteria for the `find` command
I have a folder where I keep my untagged music in which I want to launch a script to delete all the PNG and JPG files, except those beginning with the word "cover".
Here's what I tried (I ...
4
votes
1
answer
977
views
Why is the output of this find -newermt command apparently not in order?
When I run
touch a.txt && sleep 0.1 && \
touch b.txt && sleep 0.1 && \
touch c.txt && sleep 0.1 && \
touch d.txt && sleep 0.1 && \
...
3
votes
1
answer
28k
views
What does "-ls" do when used with "find"?
According to man find:
-ls
True; list current file in ls -dils format on standard output.
The block counts are of 1K blocks, unless the environment variable
POSIXLY_CORRECT is set, in ...
0
votes
1
answer
934
views
Script to convert many binary files to ASCII
I'd like to run a script, say convert.py (which converts binary to ascii, but outputs to stdout) on 30 or so *.gz files, but instead of output going to screen, it goes to a *.txt file, similar to so:
...
0
votes
1
answer
74
views
Can find recurse into some folders but not others in the same command?
I want to use find to recurse through certain subfolders in $HOME but not in others in the same command. Is that possible?
To clarify, I'd like to recurse into ~/Desktop, ~/Documents, and ~/Dropbox, ...
3
votes
1
answer
596
views
Why does find -exec only accept {} in some positions?
The following command is working fine:
find . -iname \*.7z -exec ls {} -al \;
But while I change \; to \+ , That is:
find . -iname \*.7z -exec ls {} -al \+
I got error report:
missing argument to ...
6
votes
1
answer
421
views
Adding one variable into multiple parts of an alias? alias nd='mkdir $1' works but cannot add anything after, why? [duplicate]
I have the alias
alias moveit='mkdir $1 && find -name "*$1*" -type f -exec mv -t ~/$1 {} +'
But I'm not quite sure what I'm doing wrong.
Any help would be much appreciated.
I'm trying to ...
5
votes
2
answers
6k
views
Confused about grep and the * wildcard
I am running the following command in order to find all files/directories that do not have anything to do with "flash_drive_data":
find . -not -path './flash_drive_data*' | grep "./*...
0
votes
1
answer
2k
views
Using the "not" operator with find not working as expected
I have a directory "X" with a subdirectory called "lib", as well as other files and directories. This "lib" subdirectory in turn has a bunch of directories and files itself. I am trying to use find to ...
1
vote
1
answer
49
views
Technical Issue : replace names with " find "
I am trying to replace names in the files from (token) to ( take ) by using :
find ./ -type f -readable - writable -exec sed -i "s/token/take/g" {} \;
but I got this :
find: paths must precede ...
3
votes
2
answers
5k
views
find extremely slow on CIFS share
Entry in /proc/mounts:
//OUR_ORG.file.core.windows.net/OUR_ORG /data/csv cifs rw,relatime,vers=3.0,sec=ntlmssp,cache=strict,username=OUR_ORG,domain=,uid=0,noforceuid,gid=0,noforcegid,addr=SOME_IP,...
0
votes
1
answer
51
views
I don't know how to access my created file
I'm trying to connect my home wifi to my machine with wpa_supplicant but don't know the path to the file with SSID and passphrase. If I do ls -a -1 | less from my user account I can see it in the list,...
3
votes
1
answer
756
views
Does running `find . -type d -exec chmod` in the root directory causes problem?
I accidentally ran
find . -type d -exec chmod 0755 {} \;
inside the home directory after using cd ~. Is there any side effect when running this command inside ~ or /?
0
votes
3
answers
580
views
How to treat an output of find as a string not a refrence to a file or directory
when I run
find ~/foo/bar/. -mindepth 1 -maxdepth 1 -type d
I get an output of all subdirectories of the given path. e.g.
/home/user/foo/bar/a
/home/user/foo/bar/b
...
/home/user/foo/bar/abcd
...
1
vote
1
answer
235
views
Using find in systemd service results in error: 'paths must precede expression'
I'm trying to create an exclude file, before my backup runs. Using this simple find command produces the correct output, but it fails when used in a systemd service. I think because of find escaping.
...
0
votes
2
answers
181
views
Locating certain files in Ubuntu 18.04 LTS
I see many methods of searching (or finding) files in current directories or even a specific tree, but am unable to locate an option for me.
I have an Ubuntu 18.04 LTS setup with 14 drives mounted ...
9
votes
4
answers
804
views
How do I get a list of only the files (not the directories) from a package?
Using dpkg -L <package name> I am able to obtain a list of all the files from a package, but it contains a list of directories as well, which I want to exclude.
So, for example:
dpkg -L elixir
...
5
votes
1
answer
319
views
Why does running the "find" command a second time complete quicker than the first time?
When I run time find ~ the first time, meaning the first time I run find in a session, it takes longer than than when run a second time. Why is that?
First run:
real 0m12.410s
user 0m0.424s
...
2
votes
1
answer
478
views
how to delete all but X last items from find
I want to find some dirs and delete all but the 10 latest dirs.
I can find . -maxdepth 1 -type d -name "XXX*" | xargs rm -rf but that would remove all of them.
I can't use head / tail because I don'...
1
vote
1
answer
196
views
Find files younger than a certain date containg a certain key word
How can I find/list all python scripts that are younger than a certain date and containing a certain word? I would also like to print the modification date in front of each file name if possible.
So ...
-3
votes
1
answer
259
views
Find all regular files that were modified less recently than another file
Find all regular files that were modified less recently than the *** file (which can be found in @@@/###/&&&).
How can I solve this problem? Please tell me various methods.
0
votes
1
answer
302
views
How do I send files with netcat using find?
I am trying to send a large number of json files via netcat, but I can't seem to get the find -exec combination right.
I am in the directory with the json files and have tried the following:
find -...
0
votes
1
answer
602
views
How to find multiple files with specific pattern using or in find command
Is it possible within the find command to use or to specify multiple patterns to look for using regex or any other means? For example, I am looking for all files that aren't .bashrc or .profile in a ...
0
votes
1
answer
1k
views
While loop does not work, it reads the first line and exits and the locate command that is used does not output the value
We have a shell script which should read line from a file, where the file contents are the filenames, we need to locate the path of these filenames and copy to a different directory.
Here we have ...
0
votes
1
answer
2k
views
Invalid mode '+6000' with find -perm
I followed an instruction to prepare LPIC and encounter such a find instruction
$ sudo find / -perm +6000 -type f
[sudo] password for Christine:
/lib64/dbus-1/dbus-daemon-launcher-helper
/home/...
5
votes
1
answer
3k
views
Copy large number of files of specific date to another directory?
I've around 11K log files of specific date let say 26Feb inside one directory(there are other date data also). To copy only 26th Feb log files to destination from linux command line, I use below ...
0
votes
1
answer
285
views
Current time and modification time of a file
How does the ctime and mtime differ for a file in find command?
For example, will
find . -ctime +1
and
find . -mtime +1
give the same result or not?
2
votes
2
answers
658
views
Find folders and delete contents
I want to find all folders that have a particular name and then delete all contents but not the folder...
This is to find the folder:
find /home/ -type d -name 'myname'
Now how to delete all ...
1
vote
2
answers
122
views
Script using find runs fine when I execute it, but does not run correctly from cron
Can anyone tell me what is wrong in this script?
It is not working in cron, but works fine when I execute it normally.
Warning: this command is dangerous and may delete lots of files
#!/bin/bash
/...
1
vote
2
answers
1k
views
Writing a find command with ffmpeg to process videos
I want to write a command or script to find all my .mkv videos larger than 3Gb, then run ffmpeg to make them smaller (720p) and change the extension to mp4. I have it working except the file ends up ...
3
votes
2
answers
198
views
conditional find output missing
Im trying to build a conditional statement to search for files of a certain size (in this case 1Gb.
if [ "find /location/sub/int/ -size +1G" ]
then
> /location/sub/int/large_file_audit.txt
fi
...
0
votes
1
answer
166
views
How to replace consecutive characters from directory names, recursively
What is the best way to replace all consecutive characters such as _+-."'? from a directory and all sub directory's names using GNU bash, version 4.3, using tools awk, sed, Perl rename or find?
AS ...