Grep command works in testdir, but not in the "real" directory

I just thought I found my solution because the command works in my test directory.

grep -H -e 'author="[^"].*' *.xml | cut -d: -f1 | xargs -I '{}' mv {} mydir/.

But using the command in non-test-direcory the command did not work: This is the error message:

grep: unknown option - O
Usage: grep [OPTION] ... PATTERN [FILE] ...
Try `grep --help 'for more information.

Even this did not work:

$ grep -H author *.xml

or that:

$ grep -H 'author' *.xml

(same error message)

I suspect it has something to do with file names or number of files. I have almost 3,000 files in a non-test directory and only 20 in my test directory. In both directories, almost all file names contain spaces and "-".

Additional Information:

  • I am using Cygwin.
  • I am not allowed to change file names
+3
1

():

grep -HlZ 'author="[^"].*' -- *.xml | xargs -0 -I {} mv -- {} mydir/

()

  • "" , -O. *.xml grep - (). mv. Common options info coreutils, --, . -- , .

  • -l ( L), grep , cut.

  • , -Z grep -0 xargs.

  • -e, -.

, !

+1

Source: https://habr.com/ru/post/1754810/


All Articles