Tagged Questions
2
votes
2answers
51 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
65 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
79 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
87 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
45 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
89 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
56 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
406 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
147 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
205 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
87 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
34 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
306 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.
2
votes
1answer
253 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?
0
votes
3answers
611 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
164 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
136 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
710 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 ...
5
votes
4answers
3k views
Linux command to find files changed in last n seconds
Linux command to find files changed in last n seconds.
Please suggest shell script,that we can run from cli or command.
3
votes
1answer
138 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
274 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
524 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
3answers
1k 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
722 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
744 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
1k 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
1k 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?
6
votes
4answers
7k views
Delete matching files in all subdirectories
How can I remove all .swp files in all of my subdirectories under Linux?
3
votes
4answers
1k 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 ...
67
votes
6answers
36k 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
282 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:
...