4
votes
3answers
46 views

Using Unix's find command to find directories matching name but not subdirectories with same name

Edited: I mistakenly misrepresented my problem. A more accurate example now appears below. I'd like to recursively walk all directories inside a target directory, and stop each recursive call after ...
0
votes
1answer
28 views

Two ways - two different results

I ran two seperate commands each one produced a different number. Can anyone help me figure out why? find -type d -name *log* | du -hcs find . -type d -name '*log*' -print0 | xargs -0 du -hcs
0
votes
1answer
24 views

Find and delete line in .htaccess file

I am trying to figure out how could possible a command do search and delete line from .htaccess file . the following line is the line i want to search and delete RedirectMatch ...
0
votes
3answers
49 views

How to exec two commands in one find

I would like to find specific folders echo their name ls -l their contents My problem is that I don't know how to combine an echo {} and an ls -l {} in one find command. line for echo: sudo ...
2
votes
1answer
32 views

*nix find -type flag: can it accept multiple types?

I want to use find for getting all simlinks and regular files. I can use the -type for these individually, and I can use -o to string them together, but I apparently can't do -type fl. Is there a way ...
0
votes
1answer
32 views

How to find and copy files with spaces?

I am trying to find mp3 files in any subdirectories and to copy them, for example, in the current directory. Here is the command I tried: find . -name *.mp3 -ls | gawk '{printf("cp %s .\n", $11);}' ...
1
vote
1answer
49 views

Linux find command copy found files

I have mounted an image and have used the find command to show all file types found on the image ~/mounted $ find . -type f -exec file {} \; I know how to direct the output of the command to a .txt ...
0
votes
1answer
141 views

Batch run mogrify including subdirectories

The command mogrify -format jpg *.NEF when run in a directory converts all *.NEF files to JPEGs. What I want to do is to be able to run mogrify in *.NEF files inside subdirectories as well using one ...
1
vote
2answers
484 views

find command: search for files owned by many users in one command

In Linux, is there a way to do a search for files owned by multiple users (or group(s) of users) with the "find" command? Something like this? find . -user john, akido
2
votes
1answer
240 views

Recursively delete all .exe files with the same name as the containing folder

I want to delete all .exe files in the current folder and all the sub-folders. I read that find . -name "*.exe" -exec rm -f '{}' \; will do, but I want to do the delete only if the container folder ...
4
votes
2answers
174 views

How make a compressed tar when there are too many filenames for the shell to expand on a single line?

Normally I would just do something like: tar -czf archive.tar.gz *.csv But when there are too many files in the directory for the shell to expand on a single line this doesn't work. In these cases ...
1
vote
2answers
134 views

rm -r: exclude certain subdirectories

The problem I have a directory structure, e. g. something like this (here trailing slashes represent folders): ./A ./B/A/A ./B/A/B ./B/B/ ./B/C ./C/ And I need to recursively remove everything ...
1
vote
1answer
138 views

What does “{} \;” mean in find (in Linux)?

Sometimes I see a command like find . -name * -exec ls -a {} \; I was asked to execute this. What does {} \; mean here?
0
votes
3answers
141 views

Using xargs with find

I want to exclude some directories from searching files and than run the find command to find required files. I am using below command find . -maxdepth 1 -type d | grep -E -i 'sensors' | grep -v ...
1
vote
2answers
63 views

Checking version of Applications installed in ~/Applications with unknown username

I'd like to check the version of Firefox through Apple Remote Desktop of all managed computers. I have written this, but it only checks for Firefox in /Applications /bin/cat ...
1
vote
1answer
86 views

Linux command find -print. When to I need this option?

What is the difference between: find . -name "*.txt" and find . -name "*.txt" -print ? I mean what is the use of print in find. I see that it prints the results anyway so why is this option ...
1
vote
1answer
148 views

Find command doesn't work for certain subdirectories

I just downloaded some source code from a repository and I'm trying to locate a specific file in it. For simplicity, assume that the entire project has the following directory hierarchy ...
3
votes
2answers
798 views

Efficient way to search string within file find and grep

I am searching all files containing a specific string on a filer (on an old HP-UX workstation). I do not know where the files are located in the file system (there are many directories, with hudge ...
4
votes
3answers
5k views

On Linux, how can I find all files that contain a string and delete them?

I want to delete all files that contain the string foo. How can I do this using bash in Linux?
0
votes
2answers
276 views

Finding not empty directories without subdirectories and specific sorting

I have a problem with my "homework" on studies. I have to list all not empty directories from /var and /usr, which do not have subdirectories and their owner is not root user. Also, for each ...
1
vote
2answers
2k views

How list file by range of date?

I would like to list files with 3 days years old. I found this one at stackoverflow: find . -type f -printf "%-.22T+ %M %n %-8u %-8g %8s %Tx %.8TX %p\n" | sort | cut -f 2- -d ' ' | grep 2012 But I ...
-3
votes
3answers
175 views

How to comble find and file command? [closed]

My teacher gave me a homework on combining find and file Use find and file to display all files in the /home subdirectory tree, as well as a guess at what sort of a file they are. I tried ...
6
votes
2answers
489 views

Why is the grep/-r/--include combination slower than the find/-exec/grep combination?

From my understanding, the two following commands roughly accomplish the same thing: Command 1: find -name "filename.xml" -exec grep someString {} \; Command 2: grep -r --include=filename.xml ...
0
votes
2answers
413 views

Using wildcard to find (and delete) matching files on a Linux box

I want to delete a specific config file for Awstats for every user on the box. What is the best way to delete them, and possibly, in one line? All the files are under /home and have this structure: ...
3
votes
1answer
291 views

Linux: find first result from specified search path

If I have a colon-separated path list, much like $PATH, but not neccessarily $PATH. I want to search that list for a specific file name. However, I only want the first matching path. I have ...
5
votes
4answers
2k views

Gracefully deleting files older than 30 days

I have a cache folder with minimum of 15000 files. I tried this: find cache* -mtime +30 -exec rm {} \; But this made my server load fly to the skies! Is there any faster/better solution? Or can ...
0
votes
2answers
211 views

Use test to check for condition with find and execdir option

I think I can keep my question short. Why does the following command produce no output? find /usr/share/themes -mindepth 1 -maxdepth 1 -type d -execdir test -d {}/gnome-shell \; I expected it to ...
2
votes
4answers
926 views

Finding subdirectories inside all directories with the same name

I want to run a command to: Find all directories named "inc" under a folder "X". List all the subdirectories under each "X/.../inc/". Redirect the output to a file named "list" I tried various ...
6
votes
3answers
4k views

How can I search a file by its name and partial path?

Often I have a file name and it's partial path, e.g. "content/docs/file.xml". Is there a simple way to search for that file, without manually cutting into parts its name to provide directory name ...
1
vote
2answers
280 views

List all files in a directory matching a string and copy output

I'm trying to create a series of playlists on my MP3 player, running Rockbox, by finding a file matching a string, using find /cygdrive/g/MUSIC -type f -name "Search Criteria" | ...
4
votes
1answer
169 views

Why does $ find -delete not work sometimes?

I think what I'm talking about is this part of the manpage, which is just barely too indecipherable for me: -delete ... It will not attempt to delete a filename with a ``/'' character in its ...
3
votes
1answer
441 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?
3
votes
2answers
215 views

How can I speed up a selective deep copy command in unix?

I am (ab?)using the unix 'find' command to recursively export files from a directory tree that is littered with .svn directories. This command takes a long time to run. Is there a faster way to ...
6
votes
1answer
14k views

DOS Batch file to find “new” files by date

My PC has entered an infinite BSOD loop - but I do have access to a safe-mode command prompt. I'm trying to get an idea of "what changed" that might have triggered this. e.g. I might have gotten a ...
1
vote
3answers
194 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. ...
1
vote
6answers
1k views

Finding files based on date, without using `find`

I know find can do what I am looking for, but I am wondering if there is an alternative way to find files on the filesystem either created before/after a certain point, or at a certain time. ...
4
votes
2answers
847 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 ...
7
votes
3answers
12k views

What's the difference between the find and findstr commands in Windows?

In Windows, what are the differences between the find and findstr commands? Both seem to search for text in files: find C:\> find /? Searches for a text string in a file or files. FIND [/V] ...
2
votes
1answer
44 views

find command unpredictable behaviour?

I am working on a remote machine,the disk space on the HP-UNIX machine was 96% so I was going to reduce the disk space by zipping some "*.extract.sys" files. $find . "*extract.sys" -exec ls -lrt {} ...
1
vote
2answers
370 views

Unix, find command, and false negative

Performing a search from the current directory where this file resides, this find command finds the file. # find . page.tpl.php However, when I search from a child directory, this command, # find ...
4
votes
2answers
1k views

How to rename all files and directories in current folder?

I have a directory structure like this: ./ whatever/ foos_whatever.ext something/ foo/ 1.ext 2.ext another/ foo.ext I want to rename all files and directories that ...
6
votes
4answers
354 views

How can I use find to select users with a certain amount of disk space usage?

I want to find all users shown in the /home/ directory whose disk consumption is more than 500MB. The following command works as expected. cd /home/ && du */ -hs 68K ajay/ 902M john/ ...
2
votes
1answer
1k views

How do I use the Find command in windows command-line to match the first character only?

For example if the dir command produces something like this: > dir file1.txt file2.txt another file3.txt another file4.txt I want to be able to filter all file names that start with the letter ...
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?
22
votes
3answers
9k views

How do I execute multiple commands when using find?

I'm trying to run multiple commands on things I have found, how can I achieve this? find . -exec cmd1; cmd2 does not seem to work; it instead runs cmd2 after cmd1 has been executed on every file.
1
vote
1answer
398 views

using the findstr command [duplicate]

Possible Duplicate: dispaying part of a file with the fndstr command I just want to find these two words "hello there" in all directories and all files in my a: using the command prompt ...
3
votes
3answers
425 views

Finding file names without directories

How can I use find to find files without the preceding directory (./) in a way that also works with -exec? My goal is to grep through an Apache log to see if any of the files have been accessed ...
2
votes
2answers
8k views

Unix - List all directories and subdirectories, excluding directories without files

I would like to list all the directories and sub directories in and below the current path. Since I only wanted to display directories I came up with the follwing command: find -type d -exec ls -d1 ...
4
votes
2answers
2k views

Using “find” to list only directories with no more childs

How can only directories be listed, that do not have another child directory? Imagine a structure like /A /A/AA /A/AB /A/AB/ABB /B /C /C/CC /C/CC/CCC /C/CC/CCC/CCCC I would like to use find to list ...
3
votes
1answer
3k views

How to make all files non-executable recursively using find without affecting directories?

I need to strip the executable flag from all files within a certain directory and sub directories. Right now I'm doing it with a 2 step process find /dir/ -type f -exec chmod ugo-x {} \; find /dir/ ...