find is a command line utility to search for files in a directory hierarchy
4
votes
2answers
573 views
Finding all “Non-Binary” files
Is it possible to use the find command to find all the "non-binary" files in a directory? Here's the problem I'm trying to solve.
I've getting an archive of files from a windows user. This archive ...
3
votes
5answers
215 views
get a list of directory names with find
I know I can do this to get a list of directory names:
find . -type d -maxdepth 1
but the output looks like:
.
./foo
./bar
but with ./ which I don't want. Is there a way to get find to output ...
2
votes
2answers
339 views
Remove 50GB oldest files in busybox when used capacity reaches 95%
Ok i have requested a code here but initial i didn't ask to make it busybox compatible. My bad. I'm new to linux and coding.
The code needs to do the following:
Delete 50GB of oldest data (dir ...
2
votes
1answer
52 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
5answers
224 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
2answers
99 views
How to generate folder ownership lists for each user?
I'd like to generate several separate lists for each user in Ubuntu. The lists contains the files and folders belong to each user.
Using the command following list me all the users in the system:
...
1
vote
1answer
1k views
Find a file in lots of zip files (like find command for directories) [duplicate]
Possible Duplicate:
Find recursively all archive files of diverse archive formats and search them for file name patterns
I need to search for a file in all zip files in a directory.
Is ...
1
vote
1answer
256 views
rename files maching specific mtime value within directory
I use simple set of shell commands to in order to create mysqldumps daily. The script is called by cron daemon. It looks like:
presentdate="`date +%d-%m-%Y_%H:%M.%S`"
basedir="/var/db_my_backup"
...
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?
6
votes
2answers
123 views
How can I substitute into this shell command?
I have a find command that I want to substitute a list of GIDs into.
Here's the command:
find / -follow \( -group 39 -o -acl_group 39 \) -exec ls -ln {} \; 2> $HOME/error.39.log 1> ...
2
votes
4answers
508 views
Make directory copies using find
I have a directory with a bunch of subdirectories in it. Thus
/usr/local/src/ccl/ccl-1.8/x86-headers$ ls
elf gl gmp gnome2 gtk2 jni libc
Each of these directories has a further subdirectory C ...
4
votes
3answers
773 views
Use a shell variable to execute a comand
I have a unix command in a variable, it looks like this:
cmd="find /path/to/webpage -type f | grep -v .svn | xargs grep $@"
`$cmd`
find: paths must precede expression
Usage: find [-H] [-L] [-P] ...
3
votes
2answers
187 views
Find and regex
What am I doing wrong with this find expression?
; touch ook ooks
; find . -name 'ook' -or -name 'ooks' -type f
./ook
./ooks
; find . -name 'ook[s]?' -type f
[returns nothing]
; echo $?
0
3
votes
3answers
481 views
Rename multiple directories
I want to find all directories with the last subdirectory named doc, for then rename them to Doc. How can be renamed?
I've the first part:
find -type d -name 'doc'
which returns directories paths ...
5
votes
2answers
423 views
missing argument to find -exec
I want to remove certain files using find and -exec. But unlikely bash tells me, that I'm "missing" some argument.
find . -name *.png -exec rm {} /;
what do I miss?
same "missing argument" return ...
7
votes
2answers
422 views
Use find command to convert markdown files to html
Lets suppose I have files on my harddisk having extensions as .md.
I want to convert all those files to .html through find and the -exec option.
The command to convert a markdown file to html is
...
4
votes
1answer
121 views
Why does find's -exec only executes on one result?
Here's what I checked:
find mydir -maxdepth 2 -name .project -or -name .classpath
gives output:
mydir/.project
mydir/.classpath
Meanwhile
find mydir -maxdepth 2 -name .project -or -name ...
2
votes
2answers
613 views
UNIX commands help - find
I'm trying to learn UNIX commands and I'm playing this game to learn and I'm really stuck at the moment. I'm in a server through ssh and the directory is full of random files and folders and the ...
4
votes
3answers
783 views
Why piping find and grep returns nothing?
I'm trying to have grep search inside specified files that are returned by find:
find . -type d -name 'mydir*' -exec find '{}' -name '*.java' \; | grep 'MyClass'
This doesn't work.
Meanwhile, ...
10
votes
1answer
4k views
How to skip “permission denied” errors when running find in Linux? [duplicate]
Possible Duplicate:
How do I remove “permission denied” printout statements from the find program?
When I run this command in Linux (SuSE):
find / -name ant
I get many error ...
6
votes
3answers
4k views
Pipe find into grep -v
I'm trying to find all files that are of a certain type and do not contain a certain string. I am trying to go about it by piping find to grep -v
example:
find -type f -name '*.java' | xargs grep -v ...
4
votes
1answer
262 views
Find recursively all archive files of diverse archive formats and search them for file name patterns
At best I would like to have a call like this:
$searchtool /path/to/search/ -contained-file-name "*vacation*jpg"
... so that this tool
does a recursive scan of the given path
takes all files with ...
1
vote
3answers
241 views
Error in Script. Command find is skipping folders with space character
I need a script that counts the files in a directory (and sub). I've taken the followed script, and changed it to my need.
It works like it should, except for folders with space characters. I'm ...
6
votes
3answers
1k views
Find -exec + vs find | xargs. Which one to choose?
I understand that the -exec can take a + option to mimic the behaviour of xargs. Is there any situation where you'd prefer one form over the other?
I personally tend to prefer the first form, if ...
2
votes
4answers
428 views
chown all files based on file name pattern in current directory
I'm trying to chown all files whose filenames begin with ChownFileNames. I've used this command, but it doesnt seem to work:
find . -maxdepth 1 |grep 'ChownFileNames*' -exec chown hadoop:hadoop -- {} ...
1
vote
2answers
258 views
Search and delete .Trash
I have 4 large USB devices with lots of backups collected over the years.
I want to search for all .Trash folders and delete the contents on Fedora 17. I tried the following which failed:-
# ...
3
votes
2answers
357 views
How do I find a bunch of files with a string in its filename (or body text) and then move all those files to a specific folder?
Say - what if I wanted to move every HTML file in several independent directories with the word "heavengames" in its filename (and as a second question, every HTML files with the word "heavengames" in ...
1
vote
2answers
1k views
Help understanding `find` syntax on Solaris
Consider the following files:
$ find findtest
findtest
findtest/test1
findtest/test1/start.ksh
findtest/test2
findtest/test2/start.ksh
findtest/test3
findtest/test3/start.ksh
...
1
vote
2answers
118 views
Running 64bit OS , Find all 32bit programs on a system
How should I locate all 32bit programs on my system ? I'm running a 64bit OS.
(There might be some , but I forget)
3
votes
4answers
297 views
Is there a way to increase `find` speed
I am wondering is there a way to increase find speed in terminal, it doesn't make sense that using internet google to search will have a better speed than doing a local search for strings or just file ...
0
votes
3answers
182 views
Recursively rename e-mail files from .txt to .eml
Directory "$d" contains a few thousand e-mail files with the .txt extension. To open them in my e-mail client, I need to rename them to .eml
Will this command rename them correctly:
find "${d}" ...
0
votes
3answers
1k views
How to find executable filetypes?
I want to find file types that are executable from the kernel's point of view. As far as I know all the executable files on Linux are ELF files. Thus I tried the following:
find * | file | grep ELF
...
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
5answers
884 views
Execute on the basename of a find command
Suppose I have a directory structure as follows
test
test/a
test/b
Now I want to execute a command, such that in the . folder I can execute a command on the basename of the files a and b.
So ...
3
votes
4answers
815 views
Remove numbers from filenames
I've a problem modifying the files' names in my Music/ directory.
I have a list of names like these:
$ ls
01 American Idiot.mp3
01 Articolo 31 - Domani Smetto.mp3
01 Bohemian rapsody.mp3
01 Eye of ...
2
votes
1answer
841 views
How to change permissions of multiple files found with find command?
I have a directory with numerous files. Part of the files have the 755 permissions and the other part have 644 permissions. I'd like to convert the files with 755 permissions to 644. I have tried the ...
1
vote
2answers
446 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 ...
3
votes
2answers
1k views
issue with find -exec cp
Consider this example (newbie alert):
touch test0
touch timestamp
touch test1
sudo find /var/www/import -iname 'test*' -newer timestamp -exec cp {} new \;
It actually copies file test1, but it ...
0
votes
0answers
66 views
Where is the libstdc++ test suite?
I have GCC/g++ 4.7 and it works fine. But I need to run the libstdc++ testsuite but I don't find where the testsuite is on the system and how to run it. How can I do that?
13
votes
5answers
573 views
How to remove the (1) from filenames using the find command
I recently converted all of my FLAC files to a lower sampling rate of 44.1 kHz and bit depth of 24 bits (because iPhone/iPod don't support anything above that) using XLD on my Mac OS 10.7 (Lion).
...
3
votes
1answer
292 views
Deleting files by age
Is there a command to delete all the files in a directory that haven't been modified in N days? I need to clean up some old logs.
3
votes
1answer
159 views
match files based on an md5 using find
I have a bunch js and css files in a directory. Some of them have been given a name based on an md5() of their content (looks like f10521a21bb013cb81e0909809818ad6.js). I'd like to match these files ...
0
votes
3answers
93 views
Is more or find more resource intensive in finding the number of times an item lists in a file?
I recently read How to find the total number of occurrences of text and files with find command, which asked about a way to find the number of times text "abc" appears in a file. The answer there ...
2
votes
4answers
4k views
How to find the total number of occurrences of text and files with find command
I am trying to run the find command to find the total number of occurrences of a particular text string and also the number of files which has this text string.
What I have right now is this command.
...
4
votes
2answers
194 views
Append line to many files
I want to add some text to over 200,000 files
I am trying this
find . -name *.txt -print | xargs -I % echo "hello world" >> %
But nothing is happening. When i run find . -name *.txt it work ...
2
votes
4answers
926 views
find command in cygwin giving parameter format not correct
I am using cygwin in my windows machine. I am trying to do a find and it is giving parameter format not correct. Why is that?
$ ls
bootstrap.jar
catalina-tasks.xml
catalina.bat
catalina.sh
...
5
votes
4answers
1k views
Delete files of certain size range
I want to delete files which size is between certain values. For example I have the following list of files:
-rw-r--r-- 1 smsc sys 558 Apr 30 13:07 stats.sfe.1.20120430130513.xml.Z
-rw-r--r-- 1 smsc ...
4
votes
1answer
122 views
find usage - command line vs script
I am seeing different results from the find command between being run manually on the command line vs run in a script.
If I run the following on the command line:
find . -name '*.txt' ! -name ...
2
votes
3answers
199 views
`$RANDOM` is not random within `find`'s `-exec`
I'm trying to find and move a whole bunch of folders on a linux box.
All the folders are named the same, so I am using echo $RANDOM to provide a random number to use for a folder name.
echo $RANDOM
...