Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I search case insensitive in pgrep?

Tags:

bash

pgrep uses regex as pattern style. I miss the -i option of grep, to tell pgrep, that I am searching case insensitive.

An alternative is

ps ax | grep -i PATTERN

But then I have to use the PID to send a KILL signal. With the pgrep and pkill combo I can use the same pattern for killing the app.

How can I use regex's REG_ICASE on the fly on the bash?

like image 749
timomeinen Avatar asked Oct 12 '11 08:10

timomeinen


People also ask

How do you make a search case insensitive?

Case insensitive SQL SELECT: Use upper or lower functions select * from users where lower(first_name) = 'fred'; As you can see, the pattern is to make the field you're searching into uppercase or lowercase, and then make your search string also be uppercase or lowercase to match the SQL function you've used.

How do you grep a case insensitive?

Case Insensitive Search By default, grep is case sensitive. This means that the uppercase and lowercase characters are treated as distinct. To ignore case when searching, invoke grep with the -i option (or --ignore-case ).

How do you do a case insensitive search in less?

You can also type command -I while less is running. It toggles case sensitivity for searches. -i means ignore case in searches that do not contain uppercase while -I ignores case in all searches.

Which option will find string LLB in a file case insensitive?

Case-insensitive file searching with the find command The -iname option is what makes the search case-insensitive.


1 Answers

If the string is not too long:

pkill -f '[Pp][Aa][Tt][Ee][Rr][Nn]'
like image 151
Dimitre Radoulov Avatar answered Oct 18 '22 16:10

Dimitre Radoulov