Skip to main content

All Questions

Tagged with
63 votes
5 answers
42k views

How to quote arguments with xargs

Suppose that I want to delete all files in a folder that are greater than 1 MB. $ find . -size +1M | xargs -0 rm This will not delete files that have space in their names. So I want it to quote all ...
Kshitiz Sharma's user avatar
39 votes
3 answers
5k views

GNU find and masking the {} for some shells - which?

The man page for GNU find states: -exec command ; [...] The string `{}' is replaced by the current file name being processed everywhere it occurs in the arguments to the command, ...
user unknown's user avatar
  • 10.6k
24 votes
5 answers
45k views

Using a generated list of filenames as argument list -- with spaces

I'm trying to invoke a script with a list of filenames collected by find. Nothing special, just someting like this: $ myscript `find . -name something.txt` The problem is that some of the pathnames ...
alexis's user avatar
  • 5,819
21 votes
1 answer
2k views

Why doesn't 'find' show this file? [duplicate]

Using find with grep, one can locate files that match a pattern: # find | grep error ./solr-modifiedSolr4/SolrPhpClient/phpdocs/errors.html ./error_log ./includes/classes/error_log However, using ...
dotancohen's user avatar
  • 16.1k
21 votes
3 answers
16k views

How does 'find -exec' pass file names with spaces?

If I have a directory containing some files whose names have spaces, e.g. $ ls -1 dir1 file 1 file 2 file 3 I can successfully copy all of them to another directory like this: $ find dir1 -mindepth ...
EmmaV's user avatar
  • 4,087
10 votes
3 answers
51k views

Why can't find -regex match a newline?

Why does this fail? touch "$(printf "a\nb")"; find . -regex './.\n.' I also tried these, none of which work: find . -regextype posix-extended -regex '.\n.' find . -regextype posix-awk -regex '.\n.' ...
terdon's user avatar
  • 245k
10 votes
5 answers
5k views

find not recursive when given a pattern on the command line

Imagine a source tree. There are xml files everywhere. But since there is a XYZ.xml at the root of this tree it won't find my xml files. find -iname *.xml returns ./XYZ.xml instead of ./XYZ.xml ....
Olivier Toupin's user avatar
9 votes
4 answers
41k views

How do I perform xargs grep on grep output that has spaces?

I'm searching for files based on a regular expression, and then I'm trying to search those files for content. So, for example, I have something like #Find all C++ files that match a certain pattern ...
quanticle's user avatar
  • 500
7 votes
4 answers
2k views

what's the difference between using 'single quotes' or not in find command

find ~/ -name *test.txt find ~/ -name '*test.txt' I need to construct an example where the first form fails but the second still works.
Yunong's user avatar
  • 119
5 votes
3 answers
1k views

How to recursively set directory permissions with a find that lacks -exec?

My Qnap NAS is cursed with a find command that lacks the -exec parameter, so I have to pipe to something. The shell is: GNU bash, version 3.2.57(2)-release-(arm-unknown-linux-gnueabihf) I'm trying to ...
S. McCandlish's user avatar
5 votes
1 answer
8k views

Why is find not listing matching files when preceded by an asterisk(*)? [duplicate]

On Ubuntu 14.04, 64 bit, I have set /lib/modules/4.2.0-27-generic/kernel/drivers to be my current directory. I intend to search all files having net present as a sub-string. If I search with a regex ...
sherlock's user avatar
  • 646
5 votes
1 answer
580 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 '*...
JeffM's user avatar
  • 151
5 votes
1 answer
7k views

Shell script, find -name, and wildcard expansion

I'm trying to use find -name in a sh script with a previously computed complex argument for the condition. Simplified, it goes like cond="-name '*.txt*" find . $cond -ls But now I have the problem ...
Stefan's user avatar
  • 153
5 votes
1 answer
4k views

Find a file and make a symlink to parent using find and -exec

I am trying to use find to find files matching a certain pattern, and then symlink their parent directorys to another directory, this is my current script (I'm doing this on mac so -printf won't work ...
timhc22's user avatar
  • 163
4 votes
4 answers
3k views

How to escape shell metacharacters automatically with `find` command?

I've got a bunch of XML files under a directory tree which I would like to move to corresponding folders with the same name within that same directory tree. Here is sample structure (in shell): ...
kenorb's user avatar
  • 21.3k

15 30 50 per page