2
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
try
ls -l Documents/phone_photo_vids | grep ".JPG"
– Tyson – 2014-09-05T02:09:58.6771Why use grep at all anyway? Why not just
ls -l Documents/phone_photo_vids/*.jpg
? – lzam – 2014-09-05T02:10:39.733