Linux Commands: Difference between revisions

From miki
Jump to navigation Jump to search
m (→‎grep: typo)
Line 5: Line 5:
% '''grep''' ''BASIC-REG-EXP-PATTERN'' [''FILE''] # Use classic regexp (like "dma\|DMA")
% '''grep''' ''BASIC-REG-EXP-PATTERN'' [''FILE''] # Use classic regexp (like "dma\|DMA")
% '''egrep''' ''EXT-REG-EXP-PATTERN'' [''FILE''] # Same as grep -E. Use extended regexp (like "dma|DMA")
% '''egrep''' ''EXT-REG-EXP-PATTERN'' [''FILE''] # Same as grep -E. Use extended regexp (like "dma|DMA")
% '''fgrep''' ''FIXED-STRINGS-REG-EXP'' [''FILE''] # Same as grep -N. Pattern is a list of strings to match.
% '''fgrep''' ''FIXED-STRINGS-REG-EXP'' [''FILE''] # Same as grep -F. Pattern is a list of strings to match.
% grep '''-n''' ''PATTERN'' [''FILE''] # Print matched line numbers.
% grep '''-n''' ''PATTERN'' [''FILE''] # Print matched line numbers.

Revision as of 00:52, 7 September 2008

Frequently Used Shell Commands

grep

% grep -Rsl PATTERN [FILE]            # Recursive, no error output, only list filename
% grep BASIC-REG-EXP-PATTERN [FILE]   # Use classic regexp (like "dma\|DMA")
% egrep EXT-REG-EXP-PATTERN [FILE]    # Same as grep -E. Use extended regexp (like "dma|DMA")
% fgrep FIXED-STRINGS-REG-EXP [FILE]  # Same as grep -F. Pattern is a list of strings to match.
% grep -n PATTERN [FILE]              # Print matched line numbers.