Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 930845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:24:20+00:00 2026-05-15T20:24:20+00:00

I just thought I had found my solution because the command works in my

  • 0

I just thought I had 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 the 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.

Not even this worked:

$ grep -H author *.xml

or this:

$ grep -H 'author' *.xml

(same error message)

I suspect it has some relation to the file names or the amount of files.
I have almost 3000 files in the non-test-directory and only 20 in my test directory.
In both directories almost all file names contain spaces and ” – “.

Some more info:

  • I’m using Cygwin.
  • I am not allowed to change the filenames
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:24:20+00:00Added an answer on May 15, 2026 at 8:24 pm

    Try this (updated):

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

    EXPLANATION (updated)

    • In your “real” directory you have a file with name starting with -O.
      Your shell expands the file list *.xml and grep takes your - starting filename as an option (not valid). Same thing happens with mv. As explained in the Common options section of info coreutils, you can use -- to delimit the option list. What comes after -- is considered as an operand, not an option.

    • Using the -l (lowercase L) option, grep outputs only the filename of matching files, so you don’t need to use cut.

    • To correctly handle every strange filename, you have to use the pair -Z in grep and -0 in xargs.

    • No need to use -e because your pattern does not begin with -.

    Hope this will help!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I thought I had this figured out but it turns out I'm just deleting
Just wondering if you had any thoughts on this problem. I want to make
I just thought about the non-blocking infrastructure of tornado and event-driven programming. Actually I'm
I probably just haven't thought this through, or perhaps I'm simply unaware of an
I was just putting some thought into different languages (as I'm reviewing for final
I may not understand what the return statement does(I thought it just returned a
I thought to be clever and just put an transparent UIButton over an UIImageView
I thought that layout is just a widget that keeps more widgets inside. But
I was just refreshing my JavaScript/Jquery skills and I thought of making a basic
Probably I'm just too dump for googling, but I always thought char arrays get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.