Skip to main content

Linux command: grep - Global Regular Expression Print

grep command
grep command

grep, egrep, fgrep, rgrep - print lines matching a pattern

Using grep to view/display content of /etc/rsyslog.conf file without comment lines

$ grep ^[^#] /etc/rsyslog.conf

Using ls and grep to list disks and partitions

$ ls /dev | grep '[s|v|x]d$*'
sda
sda1
sda2
sda3
sda4

--invert-match

grep -iv 'that' file.txt : Show lines that do not contain'that'

egrep - keep only those lines which have at least one of the following words: the, that, then, those.

egrep -iw 'the|that|then|those'

Use 'egrep' or 'grep -E'

egrep 'the|that|then|those'
grep -E 'the|that|then|those'

Extract lines with exactly 11 characters

grep -E "^.{11}$" /usr/share/wordlists/rockyou.txt > /usr/share/wordlists/rockyou-11.txt


Practice

THM | Regular Expressions

Other resources about grep

GNU Grep 3.5

Popular posts from this blog

Powershell: Enable Firewall Log

We sometimes need to enable Windows firewall's log to troubleshoot. Here is how.

Powershell: head and tail command

Use head or tail to skim the first or last 5 lines.

[Microsoft Outlook]: Set .pst and .ost files location with ForcePSTPath Registry Key

Set .pst and .ost files location with ForcePSTPath Registry Key The ForcePSTPath registry key is supported by Microsoft Outlook 2003 and later. In Microsoft Outlook 2003 and 2007, it applies to new profiles only. Microsoft Outlook 2013 and Outlook 2016 it applies to new accounts created in a profile. Microsoft Outlook 2013 saves .pst in   %userprofile%\Documents\Outlook Files folder by default. We can change that default setting by adding a new string registry key called ForcePSTPath and set the value to the folder that we want to save those files. Set Microsoft Outlook 2013 always save new .pst and .ost files to D:\Data\Mail folder OST file reached the maximum size The OST File Has Reached The Maximum Size