Top "Grep" questions

grep is a command-line text-search utility originally written for Unix.

Bash: One-liner to exit with the opposite status of a grep command?

How can I reduce the following bash script? grep -P "STATUS: (?!Perfect)" recess.txt && exit 1 exit 0 It seems …

regex bash grep exit exit-code
Why am I getting "cat: write error: Broken pipe" rarely and not always

I am running some scripts with commands having cat pipelined with grep like: cat file.txt | grep "pattern" Most of …

linux bash grep cat broken-pipe
How do I grep this nmap scan?

I'm using nmap to scan for SSH enabled servers. This is what nmap outputs from the scan: SSH disabled server …

linux grep nmap
How can I `find` files matching pattern within a directory matching another pattern from the command line?

Say I want to find all files in /Path named file_name*. Easy: $ find /Path -name "file_name*" /Path/foo1/…

linux command-line grep locate
grep match with string1 OR string2

I want to grep 2 patterns in a file on Solaris UNIX. That is grep 'pattern1 OR pattern2' filename. The …

grep solaris
How to always cut the PID from `ps aux` command?

I'd like to get the pid from my processes. I do ps aux | cut -d ' ' -f 2 but I …

grep cut ps
xargs: String concatenation

zgrep -i XXX XXX | grep -o "RID=[0-9|A-Z]*" | uniq | cut -d "=" -f2 | xargs -0 -I string echo "RequestID="string …

grep xargs
grep substring between two delimiters

I have a lot of bash scripts that use perl expressions within grep in order to extract a substring between …

regex bash perl grep busybox
Better way of getting a GIT commit message by short hash?

I am currently getting my commit message for a certain commit hash by using this below: hash='b55da97' …

git bash awk grep git-log
Shell Script to get exception from logs for last one hour

I am developing script which will grep logs of last one hour and check any exception and send email for …

shell parsing grep solaris tail