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

Microsoft Windows Server 2012 R2 Standard Evaluation Product Key

Microsoft Windows Server 2012 R2 Standard Evaluation D2N9P-3P6X9-2R39C-7RTCD-MDVJX DBGBW-NPF86-BJVTX-K3WKJ-MTB6V

ManageEngine ServiceDesk Plus - Reset password

Let's reset the default administrator's password to 'admin'

hmailserver: Notes from the field

hmailserver is one of free open source mail servers running on Microsoft Windows operating system.