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

Printer Support

VMware: vSphere ESXi Notes

Keep playing with VMware vSphere ESXi . It is free to download and use in production environment with some limitations of course.

Microsoft SQL Versions

Source:  https://support.microsoft.com/en-us/help/321185/how-to-determine-the-version-edition-and-update-level-of-sql-server-an -- Check version -- PRINT @@VERSION Microsoft SQL Server 2012 (SP1) - 11.0.3000.0 (X64)  Oct 19 2012 13:38:57  Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: ) (Hypervisor) -- Check version -- PRINT @@VERSION Microsoft SQL Server 2012 (SP1) - 11.0.3128.0 (X64)  Dec 28 2012 20:23:12  Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: ) -- Check version -- PRINT @@VERSION Microsoft SQL Server 2012 ( SP4 ) (KB4018073) - 11.0.7001.0 (X64)  Aug 15 2017 10:23:29  Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 6.3 <X64> (Build 9600: ) (Hypervisor) -- Check version -- PRINT @@VERSION Microsoft SQL Server 2012 ( SP4-GDR ) (KB4057116) - 11.0.746...