×
Create a new article
Write your page title here:
We currently have 3,189 articles on s23. Type your article name above or create one of the articles listed here!



    s23
    3,189Articles

    Grep: Difference between revisions

    Content added Content deleted
    imported>Kunda
    m (cosmetics w/ <tt> | whaddya think?)
    imported>mutante
    mNo edit summary
    Line 1: Line 1:
    <man>grep</man>
    The grep command searches one or more input files for lines containing a match to a specified pattern.


    {{manpage}}
    * http://www.gnu.org/software/grep/

    How can I list just the names of matching files?
    :'''<tt>grep -l 'main' *.c</tt>'''


    How do I search directories recursively?
    :'''<tt>grep -r 'hello' /home/gigi</tt>'''


    Suppose I want to search for a whole word, not a part of a word?
    :'''<tt>grep -w 'hello' *</tt>'''


    How do I output context around the matching lines?
    :'''<tt>grep -C 2 'hello' *</tt>'''


    How can I search in both standard input and in files?
    :'''<tt>Use the special file name `-':</tt>'''
    :'''<tt>cat /etc/passwd | grep 'alain' - /etc/motd</tt>'''


    more on
    *
    http://www.gnu.org/software/grep/doc/grep.html


    try

    '''<tt>$ cat FILENAME|grep SUCHWORT1|grep UND_SUCHWORT2|grep -v OHNE_SUCHWORT3|grep -i SuChWoRt4</tt>'''



    [[Category:Software]]
    [[Category:GNU]]
    [[Category:Linux]]

    Revision as of 14:11, 13 April 2006

    <man>grep</man>

    see also: mansearch, man2html

    Cookies help us deliver our services. By using our services, you agree to our use of cookies.
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.