0
votes
1answer
31 views

How to use find to fill in variable in Shell script

I am making simple Shell script form some boring-ever-repeating job. Script changes directory correctly, and now I want to run other scripts based on argument I typed when running script. Other ...
0
votes
2answers
39 views

Is there a way to show “File not found” or a message alike when using the `find` command?

I'm trying to check the existence of several files, without knowing in advance where the files are located. So, I thought of find as the de facto utility to do this... It works as expected, but the ...
1
vote
1answer
22 views

How can I restrict a bash find to only specific sub-sub-directories

I'm trying to list all the files in a specific sub-directory but different directories which are themselves on a different volume. The following works, but only on a fully specific sub-directory (and ...
0
votes
1answer
51 views

Using find and wc -L to find files containing lines longer then 500 characters

I have this command: find . -name "*.php" -exec wc -L '{}' \; And I believe it gives me the count of the longest line for each file. But I'm looking for a way to only print out the count and file ...
2
votes
1answer
35 views

Are there limits to file length piped from find to xargs or using find -exec +

In question [ Find and delete all the directories named "test" in linux ] on this site, the best answer talks about using these two commands: find . -name test -type d -print0|xargs -0 rm ...
1
vote
0answers
200 views

find command with exec sh doesn't work in shell script but in commandline (raspberrypi)

I want to find "old" folders in /volume1/photo/ipcam which are named like "????-??-??" and move corresponding folders within dropbox (with the same directory structure /ipcam/...) to the subfolder ...
0
votes
1answer
20 views

post-order for find -exec?

I want to remove certain directories from a hiearchy using 'find -exec' find $rootdir -type d -name target -exec rm -rf {} \; I get error messages find: `foo/bar/target': No such file or directory ...
28
votes
5answers
865 views

Deleting millions of files

I had a dir fill up with millions of gif images. Too many for rm command. I have been trying the find command like this: find . -name "*.gif" -print0 | xargs -0 rm Problem is, it bogs down my ...
0
votes
1answer
86 views

Why is [find] running incredible fast, if run twice?

In the Dash of my Ubuntu/Linux system are two versions of the same program. To find where the corresponding .desktop files are located I used find / -type f -name 'Sublime Text.desktop' 2> ...
0
votes
2answers
326 views

Unix command for finding and deleting folders with folder names in date format

I have folder names in the below date format 20130801 20130802 20130803 20130804 20130805 20130806 20130807 20130808 . . . 20130819 Similarly ,I have folders created from past two years for each ...
4
votes
4answers
137 views

How can I find a path by providing only part of the path?

Let's say I need to find this path /<some_where_in_root>/find/this/path and the only information I have is /find/this/path. What would be the best means of locating the full directory? I ...
0
votes
1answer
77 views

How to use arguments with 'find -exec'?

I'm trying to generate static html files for all php scripts inside dir: find . -name "*.php" -exec php {} > {}.html \; But it just dumps all results to {}.html. How to do it properly? And how ...
3
votes
2answers
2k views

How do I make “find” exclude the folder it searches in?

I'm running the following command: find /var/www/html/content/processing -type d -mtime +1 -exec rm -rf {} \; I would like to delete all the folders under the processing folder (the processing ...
0
votes
1answer
1k views

Using find with -exec gzip and grep

I have a bunch of zipped up log files and I want to search them all for a string. I tried this but it's not working: find ./ -name "*.log.zip" -exec gzip -dc {} | grep ERROR \; It's giving me: ...
2
votes
3answers
251 views

Using find, xargs, etc. to output similarly named files

I have a folder full of HTML files: 001.htm 002.htm 003.htm … I want to run Pandoc on them to convert them to similarly named Markdown files: 001.md 002.md 003.md This command works on one of ...
0
votes
2answers
181 views

find -print0 | xargs -0 grep not working as expected on Ubuntu 10.04

I've got a bit of a weird issue. If I run: find . -iname '*.php' -o -iname '*.pl' -o -iname '*.html' | xargs grep -i users I get a load of errors for filenames containing spaces, but also some ...
0
votes
1answer
67 views

using find command to find string that is not at the beggining or end of a line

So I know how to find strings in a filename that are at the end or the beginning of the line using the asterisk character accordingly. Problem is I can't find a way to find a string anywhere in the ...
2
votes
2answers
184 views

Using “find” on mac doesn't locate .so files

For some reason "find" doesn't locate .so files unless they're in the same directory I'm in. For example: r-mbp:~ todd.r$ cd /usr/local/apache/modules/ r-mbp:modules todd.r$ ls httpd.exp libphp5.so ...
1
vote
2answers
100 views

FIND operands and order of arguments

I have a find command that I am unsure if I am placing my arguments correctly. find / -xdev -size -size -262144000c -o -type d \( -name .snapshot -o -name man -o -name Man -o -fstype mvfs \) -prune ...
1
vote
3answers
1k views

How to find files on Linux where only root has read permission

I want to find files in some folder like /home/mike/www/test where only root has read permissions and not any other user. EDIT: I have the sudo and permission but I want to list all files where only ...
1
vote
2answers
423 views

is there an 'upwards' find?

I found I asked this question on the wrong stackexchange site. To find files starting from a certain path, I can use find <path> .... If I want to find 'upwards', i.e. in the parent directory, ...
2
votes
3answers
471 views

How do I create a soft link to all executables in a different directory?

I am trying to create soft links to mingw's binaries in cygwin. So far I have: find /cygdrive/c/MinGW/bin/ -name "*.exe" -exec ln -s {} basename {} \; but I get: ln: target ...
0
votes
1answer
123 views

How to find files, print some standard info about those files, plus print the alpha char count of each filename?

I want something like this: find "$dir" -type f -printf '%i:<alpha_char_count_of_base_filename>:%d:%p\n' Then I want to sort first on inode number, then on alpha_char_count_of_base_filename. ...
0
votes
1answer
36 views

Speeding up file search with a shell

Do you know any way to speed up file searching with a shell? There is a lot of possibilities: find, which, whereis, ... find seems to be the most useful, but it's very slow. Perhaps, I don't know ...
0
votes
1answer
455 views

How to find all files recursively except those in a certain directory

How can I find all files in a directory recursively, except those in the .git directory? I tried the folowing: find . \! -name ".*" but that didn't work.
3
votes
1answer
483 views

How to find files that don't belong to a given user

How do I recursively search for all files or directories that do not belong to given user?
1
vote
3answers
1k views

find specific files using “find” command only in top directory

I got one probably silly question: I'm working on remote server under Solaris using ssh and my task is to find specific files in directories matching shell pattern but not go recursively deeper. ...
1
vote
3answers
196 views

How can I determine whether different commands using grep, find and xargs do the same thing?

Do these three commands do the same thing? A command that uses grep. grep "a" -r . A command that uses find. find . -exec grep "a" {} \; A command that uses a grep on a find through xargs. ...
0
votes
1answer
174 views

Execute command inside first directory of each matched result

I am working at a client who has a project where code is a mixture of different source control systems. So a layout might be like this project/a/.svn /a/subfolder/.svn /b/.hg ...
4
votes
2answers
908 views

Linux: use find to find text files?

Is there a way to specify to find that I only want text files (and not binary files)? Grep has an option to exclude binary files, so I thought find probably has a similar feature, but I've been unable ...
6
votes
5answers
7k views

Linux command to find files changed in last n seconds.

I would like a Linux command to find files changed in last n seconds. Is there a shell script or other tool that I can run from command line interface or gui?
3
votes
1answer
241 views

Confusion about using fractional +n, -n or n in find options -amin, -atime, -cmin, -ctime

I am not sure if I understood the way find ignores the fractional part when using one of these predicates to find. For e.g. I used $ find . -ctime .2 # files status changed exactly 4.8 hours ago ? $ ...
1
vote
3answers
435 views

Single quotes and variables inside a bourne shell

I have this command that I'm trying to execute in the bourne shell for Solaris 9. find ${DATADIR} -name "check_*" -type f -exec sh -c '$0 | ${PARSEDATA}' {} \; >> ${TMP_1} My problem is, the ...
2
votes
2answers
982 views

list files in specific directories older than 1 day or 24 hours

I am trying to write a simple back up script in python where I try to list the files that are 24 hours old in specific directories that I would choose. I read the manual of find and used find . ...
5
votes
5answers
2k views

Delete all empty folders, even with .svn folders in it

I'm trying to delete all empty folders within a directory. However, find . -type f -empty does not find anything because every folder contains a hidden .svn folder. How can I work around this?
0
votes
1answer
852 views

Exclude/Include files from unix find command based on program

I'm wondering if there is any way to include or exclude files from the results of find(1) based on the output or exit code of another program. Specifically I'd like to be able to run find(1) such ...
2
votes
2answers
2k views

find files within a specific directory structure but a variable parent directory structure

I want to use the find command in linux to find a specific file nested within a specific directory structure, say dir1/dir2/reqdfile. But this directory structure can itself be nested within any ...
1
vote
4answers
2k views

find with xargs

cat fileNames.txt | xargs find . -name I expect the above command to find the path of every fileName in fileNames.txt, but this command produces no output. Why?
1
vote
2answers
2k views

Bash: Find folders with less than x files

How would I go about finding all the folders in a directory than contain less than x number of .flac files?
19
votes
4answers
22k views

Delete matching files in all subdirectories

How can I remove all .swp files in all of my subdirectories under Linux?
3
votes
4answers
2k views

GNU find with -exec rm removes matches, then complains they don't exist

I have a /domains directory in which I have entries such as theawesomesite.com 0.2.v.theawesomesite.com 0.3.v.theawesomesite.com And after testing 0.3, I'll set the main domain to alias the new ...
146
votes
6answers
94k views

How to chmod 755 all directories but no file (recursively)?

How to chmod 755 all directories but no file (recursively) ? Inversely, how to chmod only files (recursively) but no directory ?
1
vote
4answers
874 views

How can I restrict find to only search specific sub-directories?

I am using find in a Bash script. How can I modify that code to include a specific directory under 'bin' , ie './bin/php/' (while still ignoring all other sub-directories of 'bin')? Current code: ...