Top "Grep" questions

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

grep without showing path/file:line

How do you grep and only return the matching line? i.e. The path/filename is omitted from the results. …

linux unix grep find
Can I grep only the first n lines of a file?

I have very long log files, is it possible to ask grep to only search the first 10 lines?

bash search grep
How to process each output line in a loop?

I have a number of lines retrieved from a file after running the grep command as follows: var=`grep xyz …

bash shell grep
More elegant "ps aux | grep -v grep"

When I check list of processes and 'grep' out those that are interesting for me, the grep itself is also …

linux grep
How to grep Git commit diffs or contents for a certain word?

In a Git code repository I want to list all commits that contain a certain word. I tried this git …

git search grep
How to give a pattern for new line in grep?

How to give a pattern for new line in grep? New line at beginning, new line at end. Not the …

bash grep newline
Checking if output of a command contains a certain string in a shell script

I'm writing a shell script, and I'm trying to check if the output of a command contains a certain string. …

bash shell grep
Using sed, how do you print the first 'N' characters of a line?

Using sed what is an one liner to print the first n characters? I am doing the following: grep -G …

shell sed grep
Fast way of finding lines in one file that are not in another?

I have two large files (sets of filenames). Roughly 30.000 lines in each file. I am trying to find a fast …

bash grep find diff
How to store command results in a variable in on shellscripting?

I want to find out number of directories and files in home directory and want to store count some variable …

bash shell unix grep command-line-interface