Find the answer to your Linux question:
Results 1 to 6 of 6
Usually, when we look for a file named, "abc.gz", the command will be: find -name "abc.gz" But how to find all files which is not named as "abc.gz"?...
  1. #1
    Just Joined!
    Join Date
    Feb 2009
    Posts
    4

    What command to find files that not meeting some conditions?

    Usually, when we look for a file named, "abc.gz", the command will be:

    find -name "abc.gz"

    But how to find all files which is not named as "abc.gz"?

  2. #2
    Linux Newbie
    Join Date
    Sep 2007
    Posts
    160
    hi kenny,

    the exclamation mark "!" negates expressions. it's in the man page under "operators".

    cheers, kai

  3. #3
    Just Joined!
    Join Date
    Feb 2009
    Posts
    4
    Quote Originally Posted by kai12 View Post
    hi kenny,

    the exclamation mark "!" negates expressions. it's in the man page under "operators".

    cheers, kai
    how should write the command?

    I tried the following but failed.

    find -!name "abc.gz"

    -bash: !name: event not found

    find -name !"abc.gz"

    -bash: !"abc.gz": event not found

    find !-name "abc.gz"

    -bash: !-name: event not found

  4. #4
    Linux Newbie
    Join Date
    Sep 2007
    Posts
    160
    Code:
    find ! -name "abc.gz"
    note the blank between ! and -name

  5. #5
    Just Joined!
    Join Date
    Feb 2009
    Posts
    4
    Quote Originally Posted by kai12 View Post
    Code:
    find ! -name "abc.gz"
    note the blank between ! and -name
    It works great now, thank you so much

  6. #6
    Just Joined! sathiya's Avatar
    Join Date
    Feb 2008
    Location
    Bangalore, India
    Posts
    97

    Arrow

    You can also use the following way for better readability.

    find -not -name "abc.tgz"

    The technique which you are asking is called as inverting match. You can find a lot of examples over here... Mommy, I found it! — 15 Practical Linux Find Command Examples

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...