grep processes list avoiding the grep itself

ps axu | grep [a]pache2
Trick to avoid the form: grep process | grep - v grep
Sample Output
user@ubuntu:~$ ps axu | grep [a]pache2
root      9399  0.0  0.1 105628  7588 ?        SNs  11:55   0:01 /usr/sbin/apache2 -k start
www-data  9401  0.0  0.1 105716  5576 ?        SN   11:55   0:00 /usr/sbin/apache2 -k start
www-data  9402  0.0  0.1 105716  5572 ?        SN   11:55   0:00 /usr/sbin/apache2 -k start
www-data  9403  0.0  0.1 105668  5028 ?        SN   11:55   0:00 /usr/sbin/apache2 -k start
www-data  9404  0.0  0.1 105716  5576 ?        SN   11:55   0:00 /usr/sbin/apache2 -k start
www-data  9405  0.0  0.1 105652  4788 ?        SN   11:55   0:00 /usr/sbin/apache2 -k start
www-data 15581  0.0  0.1 105652  4788 ?        SN   12:04   0:00 /usr/sbin/apache2 -k start
www-data 15582  0.0  0.1 105652  4788 ?        SN   12:04   0:00 /usr/sbin/apache2 -k start
www-data 15583  0.0  0.1 105652  4788 ?        SN   12:04   0:00 /usr/sbin/apache2 -k start

13
By: EBAH
2012-12-15 19:37:19

10 Alternatives + Submit Alt

What Others Think

This works: ps axu | grep apa\\che double backslash can be anywhere within the pattern
tedkozma · 584 weeks ago
I use something like this: auxer () { ps aux | grep -i "$(echo "$1" | sed "s/^\(.\)\(.*$\)/\[\1\]\2/")" }
redshadowhero · 584 weeks ago
Can someone please explain why this works?
Mikecron · 583 weeks and 3 days ago
I found the explanation given by user "leper421" here: http://www.commandlinefu.com/commands/view/402/exclude-grep-from-your-grepped-output-of-ps-alias-included-in-description 'This works because "[h]ttpd" matches only an "h" followed by "ttpd". The line that is printed by "ps aux" is "[h]ttpd" which includes the brackets, therefor not matching. Clever.'
Mikecron · 583 weeks and 3 days ago
Can also be done with awk: $ ps axu | awk '/[a]pache2/' To extract a PID: $ ps axu | awk '/[a]pache2/ {print $1}' But wasn't pgrep written to solve this ? pgrep -l apache2 pgrep apache2
zlemini · 582 weeks and 1 day ago
Hi Mikecron, sorry for late reply, this commands works because of regular expression issues. When you use square brakets in a regexp it means: a chararcter part of this set. Example: [a-z]pache: match apache, bpache, cpache, ... , zpache [a]pache: matches only apache So when you type the command it filters all the lines containins the word "apache". If you are able to see the process list (ps -ef) in the exact moment as grep runs you would see a line containing "grep [a]pache". So why the grep process isn't shown? Because regexp([a]pache) != string([a]pache) Hope this is clear. Bye
EBAH · 582 weeks and 1 day ago
Dear zlemini, I admit I didn't know pgrep. Since I work on a variety of OSes (Linux, Solaris, HP-UX) I tend to be as conservative as possible, so I prefer to use the same command on all the systems instead of variants. One example above all: one script for all OSes instead of three is easier to maintain. Anyway I'll have a look to the pgrep, I'm courious. Thanks!
EBAH · 582 weeks and 1 day ago
Thanks for your post. I’ve been thinking about writing a very comparable post over the last couple of weeks, I’ll probably keep it short and sweet and link to this instead if thats cool. Thanks. trash chute fire discharge door
Audrey10 · 82 weeks and 5 days ago
pugs puppies for sale teacup pugs for sale pug puppies for sale by owner pug puppies ohio PUG PUPPY FOR SALE NEAR ME PUG PUPPIES FOR SALE pug puppies for sale in kentucky Pug Puppies for Sale Under $500 Near Me pug puppies for sale in texas Pug Puppies for Sale Near Me Amazing! This blog looks just like my old one! It's on a completely different subject but it has pretty much the same layout and design. Wonderful choice of colors!
rahimhh21 · 78 weeks and 2 days ago
Pug Puppies for Sale Near Me pugs puppies for sale teacup pugs for sale pug puppies for sale by owner pug puppies ohio PUG PUPPY FOR SALE NEAR ME PUG PUPPIES FOR SALE pug puppies for sale in kentucky Pug Puppies for Sale Under $500 Near Me pug puppies for sale in texas pug puppies for sale $200 pugs for sale near me under $500 pugs for sale under $400 near me pugs for sale near me puppies for sale near me under $500 pug puppies for sale under $1,000 near me pug for sale pug puppies for sale under $300 Brindle Pug Pitbull Pug Mix Pugs for sale cheap Cheap pug affordable pug puppies for sale near me black pugs for sale near me White Pugs for sale pug dog for sale free pug puppies pug puppies for sale in my area mn pug breeders pug puppies indiana pugs for sale michigan PUG PUPPY ADOPTION Pug puppies for sale Pug puppies for sale near me Pug puppies near me Pug Puppies for Sale Under $500 Near Me Cute Pug Puppies Black pug puppies Black pug puppies for sale pug puppies for adoption black pug puppies for sale near me chihuahua pug mix puppies how much is a pug puppy teacup pug puppies baby pug puppies baby pug puppies for sale pictures of pug puppies pug puppies for sale in Ohio pug puppies price pug mix puppies teacup pug puppies for sale best food for pug puppy newborn pug puppies pug puppies craigslist pug puppies for sale craigslist adorable pug puppies how much does a pug puppy cost Pitbull pug mix puppies pug pit mix puppy pug puppies for sale $200 pug puppies for sale in NJ Pug puppies for sale in Wisconsin pug puppy cost pug puppy food royal canin pug puppy royal canin pug puppy food fawn pug puppy pug puppies for sale florida pug puppies for sale in Indiana pug puppies for sale in KY pug puppies for sale in NC pug dog puppy AKC Registered Pug Puppies For sale cheap pug puppies for sale near me cheap pug puppies for sale in California cheap pug puppies for sale in nj Black Pug Puppies for sale pugs puppies for sale
Perfecthomepugs · 69 weeks and 2 days ago
I love your blog site.. great colorings & style. Did a person style and design this fabulous website you as well as have you actually hire an attorney to make it work to suit your needs? Plz respond as I!|m looking to layout my own, personal weblog in addition to would wish to understand in which ough bought the following via. appreciate it Retro cars
mahmishal · 68 weeks and 2 days ago
Audio started playing anytime I opened up this blog, so annoying! RTP live hari ini
HAMZA · 67 weeks and 6 days ago
Hi! Thanks for the great information you have provided! You have touched on crucial points! Psychiatrist
sophiacharlie · 66 weeks and 6 days ago
Youre so cool! I dont suppose Ive read anything like that before. So nice to seek out somebody with some original applying for grants this subject. realy we appreciate you beginning this up. this excellent website is one area that is needed on-line, a person with a little originality. useful purpose of bringing a new challenge towards web! ??????
gabis31 · 65 weeks and 6 days ago
Youre so cool! I dont suppose Ive read anything like that before. So nice to seek out somebody with some original applying for grants this subject. realy we appreciate you beginning this up. this excellent website is one area that is needed on-line, a person with a little originality. useful purpose of bringing a new challenge towards web! ??????
gabis31 · 65 weeks and 6 days ago
As I website possessor I believe the written content here is really fantastic , appreciate it for your efforts. slot
goxah55535 · 65 weeks and 4 days ago
Very well said, your blog says it all about that particular topic.,:~`” have a peek at this site
mahmishal · 61 weeks and 6 days ago
This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!. zeus88
HAMZA · 61 weeks ago
I prefer the countless blogposts, My partner and i significantly enjoyed, I would like information regarding that, given that it is extremely great., Many thanks related to articulating. official website
mahmishal · 60 weeks and 3 days ago
It’s difficult to get knowledgeable men and women with this topic, and you appear to be what happens you are dealing with! Thanks pop over here
lahehan967 · 60 weeks and 3 days ago
You made some respectable points there. I seemed on the internet for the problem and located most individuals will associate with together with your website. debouchage bruxelles
wenilak444 · 60 weeks and 3 days ago
That is a really amazing powerful resource that you’re offering and you just provide it away cost-free!! I that can compare with discovering websites which comprehend the particular valuation on providing you with fantastic learning resource for zero cost. We truly dearly loved examining this web site. Have fun here! juragan slot88
mahmishal · 60 weeks ago
I love the look of your website. I recently built mine and I was looking for some ideas for my site and you gave me a few. May I ask you whether you developed the website by youself? Link Bong88
mahmishal · 59 weeks and 6 days ago
I felt very happy while reading this site. This was really very informative site for me. I really liked it. This was really a cordial post. Thanks a lot!. agen sbobet terpercaya
HAMZA · 59 weeks and 4 days ago
I’m not sure exactly how I discovered your blog because I had been researching information on Real Estate in Altamonte Springs, FL, but anyway, I have had a pleasant time reading it, keep it up! gta79
gabis31 · 59 weeks and 2 days ago
Nice post. I find out some thing tougher on different blogs everyday. Most commonly it is stimulating to study content from other writers and employ something from their site. I’d choose to apply certain together with the content in this little weblog no matter whether you do not mind. Natually I’ll give you a link on your web blog. Thank you for sharing. Brigade Valencia
lahehan967 · 54 weeks and 4 days ago
You definitely know how to bring an issue to light and make it important. I cant believe youre not more popular because you definitely have the gift. west palm beach financial advisor
mahmishal · 53 weeks and 2 days ago
I have read your blog it is very helpful for me. I want to say thanks to you. I have bookmark your site for future updates. nowgoal streaming
fedada · 31 weeks and 6 days ago
Perfect House Of Pugs acquired a passion for animals, and the Pug puppy in particular, at a young age since I grew up in a house with lots of dogs. It was a natural ability to know how to grow, nurture, and care for animals. I knew what the future held when I met my wife, who essentially had the same enthusiasm as I have. Being a breeder is more of a passion for me than a profession since I get to witness people's faces light up when they successfully adopt a pug puppy from our facility. It is not possible to find happiness in anything else. PLEASE VISIT OUR WEBSITE LINK BELLOW FOR MORE INFORMATION ABOUT PUG PUPPIES. PUG PUPPY ADOPTION Pug puppies for sale PUG PUPPIES FOR SALE NEAR ME PUG PUPPIES NEAR ME PUG PUPPIES FOR SALE UNDER 500 NEAR ME CUTE PUG PUPPIES BLACK PUG PUPPIES BLACK PUG PUPPIES FOR SALE PUG PUPPIES FOR ADOPTION BLACK PUG PUPPIES FOR SALE NEAR ME CHIHUAHUA PUG MIX PUPPIES TEACUP PUG PUPPIES HOW MUCH IS A PUG PUPPY BABY PUG PUPPIES PICTURES OF PUG PUPPIES PUG PUPPIES FOR SALE IN OHIO PUG PUPPIES FOR SALE IN PA PUG PUPPIES PRICE PUG MIX PUPPIES TEACUP PUG PUPPIES FOR SALE BABY PUG PUPPIES FOR SALE BEST FOOD FOR PUG PUPPY NEWBORN PUG PUPPIES PUG PUPPIES CRAIGSLIST PUG PUPPIES FOR SALE CRAIGSLIST WHITE PUG PUPPIES PUG PUPPIES FOR SALE IN MICHIGAN PUG PUPPIES FOR SALE UNDER 500 ADORABLE PUG PUPPIES BRINDLE PUG PUPPY HOW MUCH DOES A PUG PUPPY COST PITBULL PUG MIX PUPPIES PUGS FOR SALE NEAR ME PUG PUPPIES FOR SALE 200 PUG PUPPIES FOR SALE IN NJ PUG PUPPIES FOR SALE IN WISCONSIN PUG PUPPIES MICHIGAN PUG PUPPY COST MERLE PUG PUPPY FOR ADOPTION BEST PUG PUPPY FOOD ROYAL CANIN PUG PUPPY FOOD FAWN PUG PUPPY PUG PUPPIES FOR SALE FLORIDA PUG PUPPIES FOR SALE IN INDIANA PUG PUPPIES FOR SALE IN KY PUG PUPPIES FOR SALE IN NC PUG PUPPIES FOR SALE IN TEXAS PUG PUPPIES FOR SALE MN PUG DOG PUPPY AKC REGISTERED PUG PUPPIES FOR SALE PUG ALL BLACK CHEAP PUG PUPPIES FOR SALE NEAR ME PUGS PUPPIES FOR SALE CHEAP PUG PUPPIES FOR SALE IN CALIFORNIA MINIATURE PUG PUPPIES FOR SALE NEAR ME MINIATURE PUG PUPPIES FOR SALE CHEAP PUG PUPPIES FOR SALE IN NJ KNOWN FACTS ABOUT PUG PUPPIES ADOPT PUG PUPPIS RECUE A PUG PUPPY PERFECT HOUSE OF PUGS PUG PUPPIES INSTAGRAM PINTEREST QUORA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA USA
pugpuppies95 · 31 weeks ago
Acquista Ossicodone ItaliaAcquista Ossicodone Italia  Acquista cocaina crack in linea cocaina a squame di pesce italia Acquista cocaina boliviana in linea Acquista Saxenda in Linea Acquista fentermina in linea italia Acquista Ozempic In Linea Acquista Stilnox in linea italia Acquista Ambien in linea italia Acquista Quaaludes in linea Acquista Metaqualone In Linea Acquista subutex in linea italia Acquista Adderall In linea italia Acquista Ossicodone 10 mg Sandoz italia Acquista Laudano droga online Acquista ossicodone pillole Acquista desoxyn in linea italia Acquista buprenorfina in linea italia Acquista ritalin in linea italia Acquista dilaudid in linea italia Acquista ritalin in linea italia Acquista Ossicodone 30 mg Sandoz italia Acquista fentanil in linea italia Acquista Ossicodone Italia Acquista Ossicodone Italia Acquista la morfina iniettabile Italia Acquista Ossicodone 80 mg Sandoz italia Acquista Xanax in linea italia Acquista strisce di Suboxone italia Acquista vyvanse in linea italia Acquista oxycontin in linea italia Acquista Percocet in linea italia Acquista ossicodone pillole in linea italia Acquista morfina in linea italia Acquista ossicodone in linea italia Buy wood online Buy wood pellets online  dried-pods for sale  opium-pods  for sale dried-papaver-pods  dried poppy pods in USA free dried podsdried poppy pods   körkort sverigekörkort sverige köp körkort köp falsk pass BESTÄLLA KÖRKORT ONLINE buy dried poppy pods online buy opium pods buy opium pods Buy dried poppies online dried poppy pods unwashed poppy pods for sale Dried poppy pods near me Poppy seed tea dried poppy pods for craft wholesale dried flowers USA Giant dried poppy heads dried poppy pods dried poppy pods   Führerschein kaufen ohne prüfungkaufen MPU GutachtenKaufen bootsführerschein onlineSchweizer Führerschein kaufen führerschein polen kaufen ohne prüfung FÜHRERSCHEIN ONLINE KAUFEN https://eu-fuhrerscheinlegal.com/product/kaufen-deutschland-fuhrerschein/ Buy wood online Buy wood pellets online
donperi1 · 23 weeks and 3 days ago
TIMUR188 Bukan hanya sekedar memberikan statement sebagai situs tergacor 2023 saat ini, kami membuktikan dengan memberikan jaminan garansi gacor 100% atau biasa di sebut garansi kekalahan 100%. Yang di mana apabila member baru deposit dan mengalami kekalahan pertamanya maka member berhak mengklaim garansi kekalahan 100% sesuai dengan syarat dan ketentuan yang berlaku. Menarik kan ? Main slot kalah dan bisa klaim kembali saldo nya. Promo ini hanya berlaku untuk member yang baru melakukan deposit untuk pertama kali nya. Cara klaim nya juga sangat mudah sekali. Member hanya perlu melapor ke CS Livechat TIMUR188 yang bertugas 24 jam dimana fitur klaim garansi nya terdapat di bagian pojok kanan bawah di halaman situs kami. Gabung sekarang juga jangan sampai ketinggalan promo bonus menarik yang sudah ditawarkan, segera klik langsung tombol yang disediakan diatas untuk bergabung dengan Situs TIMUR188 yang sudah kami Bagikan
wandasuwari · 5 weeks and 5 days ago
Selamat datang di situs TIMUR188 Bagi kalian yang gemar bermain game online, kalian telah berada di tempat yang tepat. TIMUR188 adalah situs game online yang gacor dan terpercaya.Selamat datang di situs MAXIM178 Bagi kalian yang gemar bermain game online, kalian telah berada di tempat yang tepat.
projack · 1 week and 2 days ago
Selamat datang di situs TIMUR188 Bagi kalian yang gemar bermain game online, kalian telah berada di tempat yang tepat. TIMUR188 adalah situs game online yang gacor dan terpercaya.Selamat datang di situs MAXIM178 Bagi kalian yang gemar bermain game online, kalian telah berada di tempat yang tepat.
projack · 1 week and 2 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: