Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove line number option from grep

I use an alias for grep, that adds line numbers to the output:

alias grep="grep -n -I --color"

For a certain command I'd like to remove the -n from the grep command. I could not find a "Do not add line numbers"-flag. Is something like this available or do I have to add an extra alias without linenumbers?

like image 260
Edward Avatar asked Feb 09 '17 14:02

Edward


People also ask

How do I remove line numbers from a file in Linux?

The syntax is <address><command> ; where <address> can be either a single line like 5 or a range of lines like 5,10 , and the command d deletes the given line or lines. The addresses can also be regular expressions, or the dollar sign $ indicating the last line of the file.

How do I grep from a specific line number?

The -n ( or --line-number ) option tells grep to show the line number of the lines containing a string that matches a pattern. When this option is used, grep prints the matches to standard output prefixed with the line number. The output below shows us that the matches are found on lines 10423 and 10424.

How do I ignore a string in grep?

Exclude Words and Patterns By default, grep is case-sensitive. This means that the uppercase and lowercase characters are treated as distinct. To ignore the case when searching, invoke grep with the -i option. If the search string includes spaces, you need to enclose it in single or double quotation marks.

How do I show line numbers in less command?

You can easily display line numbers using less command. All you have to do is pass either -N or --LINE-NUMBERS option to the less command. This option forces less to show a line number at the beginning of each line in the screen.


1 Answers

You could use command to remove all arguments.

command grep -I --color
like image 107
R_User Avatar answered Oct 14 '22 04:10

R_User