Results 1 to 2 of 2

Thread: How with grep command exclude search in dubdirectory ?

  1. #1
    Join Date
    Aug 2019
    Beans
    93

    How with grep command exclude search in dubdirectory ?

    Hello,
    Under Kubuntu 18 I use command
    Code:
    grep -Hrn 'backend' --include="*.vue" /mnt/_work_sdb8/wwwroot/lar/hostels2/resources/js/components/BS4
    when I need to search for some string inside of a directory.

    I search for an option to exclude “/admin/” subdirectory, something like (that does not work):
    Code:
    grep -Hrn 'backend' --include="*.vue" --exclude="*admin*" /mnt/_work_sdb8/wwwroot/lar/hostels2/resources/js/components/BS4
    I found option to exclude :
    Code:
    grep "word1" | grep -v "word2"
    grep -r 'wanted_pattern' * | grep -v 'unwanted_pattern'
    But I failed combine it , like
    Code:
    grep -Hrn 'backend' --include="*.vue" /mnt/_work_sdb8/wwwroot/lar/hostels2/resources/js/components/BS4 | grep -v --include="*admin*"
    Got message :
    Code:
    Usage: grep [OPTION]... PATTERN [FILE]...
    Try 'grep --help' for more information.
    Which is valid format ?

    Thanks!

  2. #2
    Join Date
    Aug 2010
    Location
    Lancs, United Kingdom
    Beans
    1,588
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: How with grep command exclude search in dubdirectory ?

    Quote Originally Posted by petrogromovo View Post
    But I failed combine it , like
    Code:
    grep -Hrn 'backend' --include="*.vue" /mnt/_work_sdb8/wwwroot/lar/hostels2/resources/js/components/BS4 | grep -v --include="*admin*"
    Code:
    grep -Hrn 'backend' --include="*.vue"  /mnt/_work_sdb8/wwwroot/lar/hostels2/resources/js/components/BS4 | grep  -v /admin/

Bookmarks

Posting Permissions

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