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

hmailserver: Notes from the field

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

stegseek: Notes

StegCracker has been retired following the release of StegSeek, which will blast through the rockyou.txt wordlist within 1.9 second as opposed to StegCracker which takes ~5 hours.

VMware ESXi host loads ipmi_si_drv too long

Workaround: remove ipmi_si_drv esxcli software vib remove --dry-run --vibname ipmi-ipmi-si-drv esxcli software vib remove --vibname ipmi-ipmi-si-drv ~ # esxcli software vib remove --dry-run --vibname ipmi-ipmi-si-drv Removal Result    Message: Dryrun only, host not changed. The following installers will be applied: [BootBankInstaller]    Reboot Required: true    VIBs Installed:    VIBs Removed: VMware_bootbank_ipmi-ipmi-si-drv_39.1-4vmw.550.0.0.1331820    VIBs Skipped: ~ # ~ # esxcli software vib remove --vibname ipmi-ipmi-si-drv Removal Result    Message: The update completed successfully, but the system needs to be rebooted for the changes to be effective.    Reboot Required: true    VIBs Installed:    VIBs Removed: VMware_bootbank_ipmi-ipmi-si-drv_39.1-4vmw.550.0.0.1331820    VIBs Skipped: ~ #