find is a command line utility to search for files in a directory hierarchy
2
votes
3answers
132 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 ...
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 ...
2
votes
1answer
72 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 ...
2
votes
1answer
92 views
How to run a command against all the files of particular types on a filesystem?
I've just recovered tons of files (distributed in a complex directory structure, having very long names, using Unicode symbols, spaces etc in names) from a damaged hard drive. Now I'd like to verify ...
2
votes
1answer
53 views
How to process directory first, then files and directories under it?
On my Linux system, I've got into a situation where there are not write/execute permissions on directories on a mounted drive. As a result, I can't get into a directory before I open its permissions ...
2
votes
1answer
105 views
How to have find only search for files in changed directories?
Currently I'm repeatedly doing a 'find' that's too slow. I'm searching for non-hidden executable files within "$root", excluding "$root/bin":
find "$root" -type f -perm -o+x -not -path "$root/bin/*" ...
2
votes
2answers
130 views
find command for the newest 500 files in a directory tree and also be POSIX compliant
I am looking for a single line shell script or unix command to find the newest 500 files in a directory. Major constraints are it should be POSIX complaint and the directory can have tons of files.
2
votes
2answers
2k views
How to exclude a list of full directory paths in find command on Solaris
(Duplicated from Stack Overflow: http://stackoverflow.com/questions/7854975/how-to-exclude-a-list-of-full-directory-paths-in-find-command-on-solaris)
I have a very specific need to find unowned files ...
2
votes
3answers
3k views
use 'find' to search for directories !containing certain filetype foo
I have a few directories, some with a depth of 3, which contain mixed file types. What I need to do is to rm -rf all the subdirectories that do not contain filetype foo.
Is this achievable with find ...
2
votes
2answers
70 views
Exclude all subdirectories except one specific path in a find command
I use a find command to search for all files with a given extension within the current subdirectories ignoring certain directory path:
find -L . \( -wholename "*/ignoredPath" -o -wholename ...
2
votes
4answers
94 views
Find and copy directories containing file type
I have a directory "Movies" containing subdirectories "Movie Name". Each subdirectory "Movie Name" contains a movie file and related image/nfo files etc.
I'm trying to copy all directories containing ...
2
votes
2answers
72 views
Use a parameter in a command argument
I run a find command to search files with a name containing perl:
find /tmp -name '*perl*'
/tmp/perl.pl
/tmp/run-perl-stage.pl
But when I set the perl name in a variable PARAMETER and run the find ...
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 ...
2
votes
1answer
161 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
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 }'
...
2
votes
1answer
120 views
How to find files compared to the time of a specific file
How can I search for files that were modified or changed 5 minutes before and 5 minutes after, a certain file. I have tried
mint@mint ~/Desktop $ touch -t 201210101315 /tmp/timestamp
mint@mint ...
2
votes
5answers
226 views
Flatten Directory but Preserve Directory Names in New Filename
How can I flatten a directory in the following format?
Before: ./aaa/bbb/ccc.png
After: ./aaa-bbb-ccc.png
2
votes
1answer
232 views
Which order does find command use to print out
What order does the find command use to print out a list of files?
Is this order different across different Linux distributions or versions?
2
votes
2answers
363 views
Remove slashes/parent paths from filenames inside CSS and Javascript content
I need to go through all my css and js files and if there is a filename referenced that has any slashes (/) at all then the slash should be removed.
What I want is:
if any files referenced are ...
2
votes
1answer
94 views
Script for opening corresponding pdfs for bibtex keys in Vim
Context
I currently write research articles in LaTeX using Vim.
I have bibtex keys in my articles like \cite{smith2000sometopic} and I have corresponding pdf versions of most articles in a subfolder ...
2
votes
1answer
167 views
Web front-end to find/grep/ack
In my lab, we are trying to build a web that allows the user to enter queries for find, ack, grep on a specific directory. The web would return an HTML with a table of a list of clickable files (click ...
1
vote
4answers
306 views
What is this Bash line supposed to mean?
find . -name "*.html" -exec grep -l somethingtobefound {} \;
I was just wondering what the keywords "-name" "-exec" "-l" "{}" "\" and ";" were supposed to signify.
Also, I commonly see ...
1
vote
4answers
119 views
Syntax error in a bash script that calls find
Where is the error in this script please:
#!/bin/bash
rep="git"
files=`find' ${rep} '-type f`
for f in ${files} do
echo $f
done
When i run find git -type f alone in the shell, it works!
1
vote
4answers
621 views
A problem with find and grep
I have dafined the following in .bashrc:
alias fg='find . -name $1 | xargs grep --color $2'
in order to write
fg "*.txt" " my_text "
and find all file that have extension .txt and contain " ...
1
vote
3answers
189 views
Merging files into one also adding a new line between each file
I'm using
find . -type f \( -name "*.js" ! -name "*-min*" \) -exec cat {} \; > all.js
to merge files together. Unfortunately I don't get a new line after each file but it ends and the new file ...
1
vote
3answers
2k views
How can I grep the results of FIND using -EXEC and still output to a file?
Better to explain on examples.
I can:
find . -name "*.py" -type f > output.txt
But how can I store the output to the same file for:
find . -name "*.py" -type f -exec grep "something" {} \
I ...
1
vote
2answers
512 views
Delete files recursively that DON'T match regexp
I'm attempting to clean out a bunch of temporary files from a folder tree, but don't want to delete files that match some criteria, specifically executable files, .tpl files, and not the subfolder ...
1
vote
3answers
39 views
Apply two commands to result of find
I am trying to apply two command (echo and haml --check) to result of my find.
haml --check `find . -name "*.haml"`
# return Syntax error on line 2: Illegal nesting: nesting within plain text is ...
1
vote
4answers
140 views
Is there a command to list files, exclude sub-directories and display size and date?
Before I begin please assume I have only basic knowledge in UNIX. Basic meaning I have only started reading about it since last week for a work related purpose.
I have been experimenting with the ls ...
1
vote
1answer
77 views
What is a sure fire way to find all files and/or path that contains 2 keywords?
I was doing a
find . -iname '*sitesearch*' | grep demo
because I know the file should be some/path/SiteSearch/demo/SiteSearch.html, but it turned out a person put the file in as ...
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 ...
1
vote
4answers
482 views
Checking if a file exists in several directories
I've been working on this far too long and need some help.
I need a script that will look at files in a directory and see if it exists in one of several directories.
I need something like this:
for ...
1
vote
1answer
1k views
What is the command to find a jar file in a particular folder?
What is the command to find a jar file in a particular folder?
Say I want to find log4j.jar in the /dev directory, what command should I use?
1
vote
2answers
447 views
Use mogrify to resize large files while ignoring small ones
I'm running the following command:
mogrify -resize '400x400>' *.png
Notice the ">". Supposedly it will ignore smaller files, but although it doesn't resize them, it edits them (modification date ...
1
vote
3answers
331 views
How to move files into newly created directory on condition in shell/perl
It was a mess of music files and directory.
It is needed to perform the below operation over multiple directories at once:
If the directory contains ".jpg" files, then create a new directory
...
1
vote
3answers
192 views
Directory filenames with sed with whitespaces
I'm working on a script and I'm stuck, even with the help of teh googles.
Here's my code:
for FOLDER in `find . -type d | sed "s#^.#$(pwd)#" | sed 's/ /\ /g'`
do
echo "$FOLDER"
done
This will ...
1
vote
3answers
452 views
Help with a find command
I have a bunch of directories. Inside these directories is a cover letter and a zip archive of work. I wanted to run a quick and easy query to open up all the cover letters so I can decide if it's ...
1
vote
1answer
1k views
What is wrong with this “find all vim swap files and remove them with a confirmation” command?
I am trying to remove all vim swap file *.swp and remove them with a confirmation. The find command found the files, but rm says No such file or directory with the -i option. When I hardcode the path ...
1
vote
1answer
113 views
Listing specific lines in listed files
Find all files in /tmp that are ordinary files and print the lines
that end with Programming.
For this problem I know how to list all files in /tmp.
What I do not know how to do is whether to use ...
1
vote
2answers
488 views
Is There A Way To Find Files Containing Only Non-Printing Characters?
I've got a program that's behaving badly and has created a number of files with only a few non-printing characters. If I were to cat the files, I see nothing (since they are non-printing chars). ...
1
vote
2answers
191 views
find -exec on zsh: echo works as expected, print doesn't
I thought the following two commands would output the same thing, but they don't:
Command 1:
find . -name filename -exec print '{}' \;
Command 2:
find . -name filename -exec echo '{}' \;
...
1
vote
3answers
68 views
Setting file permissions in bash script
This script is not working the way I thought it would .I though it would find all the scripts that have every one rwx permissions changed to the permissions of xx5
#!/bin/bash
# the / makes find ...
1
vote
2answers
61 views
Why don't find and locate search /bin?
What gives? Normal find and locate commands don't turn up the verify program that lives at /bin/verify. In fact, it seems they don't turn up anything that lives in /bin
[jake@jace]/bin% "find" /bin/ ...
1
vote
1answer
51 views
chmod allowing write when I am not setting it
I've got a perl script which systematically changes permissions. The first thing the script does is remove all permissions. It does this by calling chmod(from perl). I did this as I found the set guid ...
1
vote
3answers
138 views
What does a question mark in a filename matching pattern mean?
What does the question mark in this command mean?
find . –type d –name "?d*" –print
I tried to to run it without it but didn't notice any change.
1
vote
1answer
108 views
questions on find and grep
With respect to the following find command-line
find . -type f -exec grep -l strings {} \;
I do not understand the usage of -exec and {} \ Thanks.
1
vote
2answers
90 views
How to find which files contain mentions of a wildcard image name?
What I am trying to do is do a search on my server to find which files contain mentions of images with a certain keyword in the filename but all I can figure out is how to find the filenams (not image ...
1
vote
1answer
70 views
Find both regular files and directories
How can I tell ( if I can tell !) find to find files of both the directory and file type?
find -type fd
It is like the heuristic dark ages up in here.
1
vote
3answers
257 views
Compacting `find` name patterns
I am using
find . -name '*.[cCHh][cC]' -exec grep -nHr "$1" {} ';'
find . -name '*.[cCHh]' -exec grep -nHr "$1" {} ';'
to search for a string in all files ending with .c, .C, .h, .H, .cc and .CC ...
