find is a command line utility to search for files in a directory hierarchy
2
votes
2answers
56 views
Select greatest numbered filename
Simple requirement but can't find anything online which can achieve it.
I have a list of dated files as below...
filename_20120101.dat
filename_20120102.dat
filename_20120103.dat
I ...
2
votes
2answers
103 views
find all cpp files and list only those files with names that match a pattern (regex) does not work
I have a whole repository of files and I am trying to get a list of files that match a certain criteria.
For example, let us say that I want to take all the files that have the string foo1 and ...
1
vote
2answers
54 views
How to print find match as well as run an -exec
I was wanting to run a find and then execute a script on each match; however, I was wanting to print the name of the matched file above the output from each exec. How can I produce the following ...
2
votes
1answer
45 views
Find Directory and copy another directory to found directory?
I'm attempting to find a directory A that could be in a variable location and copy another directory B into the found directory. So, I'd like to find directory A, and copy Directory B into Directory ...
5
votes
2answers
119 views
Remove all Vim undo files in all but one directory
I just realized that I have tons of Vim undo (.un~) files sprinkled around my file system. I'd like to delete all of these files except in one directory—~/.tmp. My first problem is that I can't seem ...
2
votes
3answers
76 views
How to copy a list of files and adjust destination filenames on the fly?
When I don't need to adjust destination filenames I can do something like this:
$ find -type f -name '*.pat' -print0 | xargs -O cp -t /path/to/dest
It is safe because the filenames may even ...
3
votes
2answers
231 views
find flags: -exec rm -rf vs -delete
I thought the flags I mentioned in the question are the same, but I get the following message with the former, but nothing with the latter:
$ find . -mindepth 1 -type d -exec rm -rf {} \;
find: ...
5
votes
3answers
386 views
List the files containing a particular word in their text
I would like to list the files recursively and uniquely that contain the given word.
Example: Checking for word 'check', I normal do is a grep
$ grep check * -R
But as there are many occurrence ...
0
votes
2answers
154 views
How to find and replace a particular string in a specific line
I developed a code which find and replaces a specific string in all xmls under all subdirectories. But i dont want all occurances to be replaced. In entire xml, code should find the tag xyz and ...
0
votes
2answers
558 views
How to use the find command in Perl script?
Could someone tell me why the find command always go to the root directory but not the directory that is specified in $srceDir?
my $srceDir = "/mnt/SDrive/SV/Capture Data/";
my $find_cmd = 'find ...
0
votes
1answer
63 views
Error trying to call find from perl
use warnings;
use File::Find;
my $srceDir = "//mnt/Share_Drive/Verizon PM&T/Capture Files/";
opendir(DIR, $srceDir) or die "Can't open $srceDir: $!";
my @files = (find -type f -newermt "12 Feb ...
2
votes
2answers
375 views
list all files newer than given timestamp and sort them
I want to list all files (sorted by date) that are newer than timestamp in format 20130207003851 in directory /tmp only. Subdirectories can be omitted.
Using SUSE Linux Enterprise Server 11.
The ...
4
votes
1answer
94 views
How to search file based on DAY of week
Actually I need to search for files and folder that were created in 2012 on Friday of every month.
I did some attempts using the FIND command but it didn't work.
1
vote
2answers
192 views
Unix: find directory filenames listed in a text file and move to new directory
I'm a command line novice trying to figure out the appropriate command to execute the following within the Terminal in Mac OS X.
Assuming I've placed all files in the same directory, I want to ...
3
votes
2answers
169 views
How to exclude NFS directories with find?
I need to search for files that has no user OR no group.
find / -nouser -o -nogroup
I think this is OK. But, I don't want to search NFS shares. How can I exclude the NFS shares in the find ...
2
votes
1answer
157 views
Exclude symbolic links to other filesystems with find -mount
I am working on a script that, among other things, extracts a list of all items in a directory (files and subdirs) for archival but it needs to skip remote symlinks (i.e. on other file systems). The ...
2
votes
3answers
131 views
Howto recursively create PDF thumnbails on linux command line
I am able to use ImageMagick to create a thumbnail of the first page of a PDF using:
convert -thumbnail x80 95.pdf[0] thumb_95.png
This works fine and generates a thumb_95.png file.
I have tried ...
1
vote
1answer
72 views
Speeding a find rm command with test through parallelization
I want to recursively delete all files in directories and subdirectories with number of lines less than 10, and am currently using the following command
find . -type f -name "*.txt" | while read; do ...
2
votes
3answers
138 views
Use find + sed + cp to find files and copy them to a directory with a different name
I'm trying to copy a bunch of files named folder.jpg into a folder. The problem is because all the files are named the same thing, I need to rename them in the process. I know I can probably do it ...
0
votes
1answer
104 views
Move video files to directory by width
I'm trying to move video files to directory by width of that video file.
For example I have
./xxx/pr0n.mkv
./pokemon.mkv
After running script
./xxx/1920/pr0n.mkv
./1920/pokemon.mkv
If I run ...
2
votes
2answers
323 views
How to find inode number using “find” command?
How do you find the inode number of the name of files that start with a particular keyword like "test"?
We'll assume that there are files called: test, test1, test2.
2
votes
1answer
128 views
How to find old directories in local directory using find in AIX?
I need to find all old directories in current directory.
find in AIX does not provide -maxdepth parameter.
There is only -depth and -prune parameters.
It is possible to write something like following: ...
14
votes
2answers
668 views
How to stop the find command after first match?
Is there a way to make the find command to stop right after finding the first match?
0
votes
1answer
563 views
Using 'find' for recursive search and delete
My queston is kind off a basic * nautilus at time cant do well at recursive search & related operations...
I want to search files having name libre in them & then delete them...
I am half ...
2
votes
1answer
220 views
Help me parse this `find` command
Following command tells me the length of mp4 video files:
find -type f -name "*.mp4" -print0 | \
xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | \
perl -nle ...
3
votes
3answers
117 views
Find functions, commands, and builtins [duplicate]
Possible Duplicate:
Executing user defined function in a find -exec call
Suppose I have the following bash code:
!#/bin/bash
function print_echo (){
echo "This is print_echo Function" ...
2
votes
2answers
84 views
What is an equivalent of rm `find lib/ -name *.swp` without find?
As in the title, I would like to remove all files in the lib directory with .swp in the end.
How can I do this without find in:
rm `find lib/ -name *.swp`
3
votes
1answer
51 views
Omitting extension with find?
I need to create thumbnails from multiple .png files and would like to do this using ImageMagicks convert utility. To recursively find all files that are not thumbnails themselves, I am using the ...
0
votes
1answer
61 views
Alter path of find result [duplicate]
Possible Duplicate:
Manipulate file name piped from find command
How can I alter the path of a file found with find before I run an exec on it? I want to find files and then mv them to a ...
3
votes
1answer
132 views
Recursive find that does not find hidden files or recurse into hidden dirs
I am wanting to search recursively through a directory and find all files that are not hidden files themselves and are not in a hidden dir. I tried using find . -type f -not -name '.*' which excludes ...
2
votes
1answer
78 views
How to have find recurse into subdirectories when using -prune option
I see that the find command does not descend into subdirectories when you're using the -prune option. How do I tell find to recurse into the sub directories, but also ignore some stuff?
...
2
votes
2answers
133 views
comm fails on bash variable input
I have a script that's supposed to get the list of files of two directories, get differences and execute some code for certain files.
These are the commands to get the file lists:
list_in=$(find ...
1
vote
2answers
222 views
Command to find file/path lengths that are too long for burning to DVD?
I'm trying to burn a DVD from Windows but it fails because the full path name length exceeds the limit of something like 255 characters.
Our files are stored in Debian Linux (accessed by Windows ...
2
votes
5answers
104 views
Find folders containing a file
How can I find all subfolders containing a given file?
For example, in a Minecraft server installation, the different worlds are stored in subfolders with arbitrary names. To identify that a given ...
1
vote
3answers
224 views
Find files in multiple folder names
I am trying to list all the files from dir1, dir2, dir3 and dir4 which might be anywhere in as a sub directory of my cwd using the find command. I tried the following with no success:
find . -type f ...
2
votes
2answers
185 views
Get total size of jpeg images per directory in each directory containing jpegs
I'm trying to get a per-directory total size of all the .jpg/.jpeg images in each directory that contains such images. And showing the full directory path.
I'm no bash expert but I've managed to ...
0
votes
2answers
202 views
variables in find command and more shell problem [duplicate]
Possible Duplicate:
Recursive rename files and directories
I wrote the following script:
#!/bin/bash
SAVEIFS=$IFS
alias export='export'
IFS=$(echo -en "\n\b")
find $1 -name "*" ...
2
votes
1answer
88 views
IOStat report large ocassional writes but find reports no big file
root@host [/home4]# find . -type f -size +2000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
...
1
vote
2answers
157 views
What is wrong with this call to sed -i?
I have this line
find . -type f \( ! -name '*.plist' \) -and \( ! -name '*.mp4' \) -and \( ! -name '.DS*' \) -print0 | xargs -0 sed -i 's/AAA/BBB/g'
my intention is from the current directory ...
2
votes
3answers
193 views
Manipulate file name piped from find command
I'm relatively new to Bash and am trying to do something that on the surface seemed pretty straightforward - run find over a directory hierarchy to get all of the *.wma files, pipe that output to a ...
13
votes
3answers
601 views
locate vs find: usage, pros and cons of each other
In Linux and Unix systems there are two common search commands: locate and find.
What are the pros and cons of each? When one have benefits over the other?
5
votes
4answers
423 views
Delete all folders containing files which match pattern
I'm trying to delete all subdirectories of my current working directory which contain a rar file.
My first attempt: find -name *.rar -exec rm -r {}/.. ';' failed because that is not a valid ...
1
vote
0answers
43 views
GUI for find which can show video thumbnails
Is there a GUI for find (or just a graphical search tool which supports regex searches on filenames starting from a specific directory) which is able to show thumbnails found video and image files?
I ...
1
vote
2answers
99 views
find “an expression” on each file of a directory recursively
One of my website on my webserver has suffered an attack : code injection.
Here is the malicious code :
<script type=\"text/javascript\" language=\"javascript\">
(function () {
var t ...
3
votes
3answers
523 views
Preserve directory structure when moving files using find
I have created the following script that move old days files as defined from source directory to destination directory. It is working perfectly.
#!/bin/bash
echo "Enter Your Source Directory"
read ...
10
votes
6answers
320 views
How to find files with 100% NUL characters in their contents?
What is the Linux command-line command that can identify such files?
AFAIK the find command (or grep) can only match a specific string inside the text file. But I want to match whole contents, i.e. ...
-1
votes
1answer
103 views
Error while running bash script that moves files
I am new to bash script and want to create bash script that moves some days old files between source and destination as per days defined in script.
When I run this script I get error
find: paths ...
6
votes
1answer
125 views
tar: how can I exclude intermediate directories but include leaf directories?
I want to create a tar file suitable for extracting into /. I've created a work directory that represents the root of the file system, and it has all the stuff I want included in the tar underneath, ...
1
vote
2answers
741 views
Compress old log file into single zip-linux
I have a folder /home/testuser/log which contain log files of one day old *.log. I wish to compress all the log files older than one day to a single zip(gzip or tar.gz) and delete the older files.
I ...
2
votes
1answer
71 views
Find: Reference to Current Directory
I'm trying to use find with the regex option. However my regular expression only captures the basename of the file. Is there a reference to the "directory find is currently in" I can use in my regular ...

