When I run this command ls -l Documents/phone_photo_vids
, I get 100s of entries in the following format. Notice the endings of the images are either PNG or JPG
-rw-r--r-- 1 moi staff 189280 Oct 29 2011 IMG_0041.PNG
-rw-r--r-- 1 moi staff 2481306 Oct 29 2011 IMG_0042.JPG
I then decided that I only wanted to see the jpg results, so I ran both of these commands, both of which returned no results
ls -l Documents/phone_photo_vids | grep "*.JPG"
ls -l Documents/phone_photo_vids | grep "*.JPG$"
I would have expected both of the grep commands to filter out all the files ending in PNG, and return all the files ending in JPG, but I got nothing. How am I using grep incorrectly?
I'm working on a Mac OSX 10.9.3
Best Answer
Some form of answers are WRONG although it works like it claims most of the time.
So to have the best result, try these ones: