Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the grep command #1422

Merged
merged 5 commits into from
Oct 20, 2023
Merged

Adding the grep command #1422

merged 5 commits into from
Oct 20, 2023

Conversation

RafBishopFox
Copy link
Collaborator

This PR adds a new command called grep. grep searches the contents of files for a given search pattern. The command is useful when you want to find files that have information that you care about without having to download the entire file. The search pattern can be a literal string or an RE2 regular expression. grep supports recursion and context (returning lines before and after the matching line).

For binary files, context results are disabled.

Some samples:
Basic search:

sliver (CRUEL_BEAVER) > grep -i root|polkit /etc/passwd

Found 2 matching lines for root|polkit in /etc/passwd

/etc/passwd: Line 1: root:x:0:0:root:/root:/bin/bash
/etc/passwd: Line 5: polkitd:x:483:483:User for polkitd:/var/lib/polkit:/usr/sbin/nologin

Same search with context:

sliver (CRUEL_BEAVER) > grep -i -C 2 root|polkit /etc/passwd

Found 2 matching lines for root|polkit in /etc/passwd

/etc/passwd (match on line 1)

root:x:0:0:root:/root:/bin/bash
systemd-timesync:x:497:497:systemd Time Synchronization:/:/usr/sbin/nologin
messagebus:x:484:484:User for D-Bus:/run/dbus:/usr/sbin/nologin


/etc/passwd (match on line 5)

messagebus:x:484:484:User for D-Bus:/run/dbus:/usr/sbin/nologin
mysql:x:60:60:MySQL database admin:/var/lib/mysql:/usr/sbin/nologin
polkitd:x:483:483:User for polkitd:/var/lib/polkit:/usr/sbin/nologin
scard:x:482:482:Smart Card Reader:/run/pcscd:/usr/sbin/nologin
wsdd:x:481:481:User for wsdd:/run/wsdd:/usr/sbin/nologin

@RafBishopFox RafBishopFox requested a review from a team as a code owner October 4, 2023 14:44
@rkervella rkervella merged commit b7d0dcc into master Oct 20, 2023
5 checks passed
@RafBishopFox RafBishopFox deleted the grep branch November 1, 2023 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants