Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am new to linux. Is it possible for a ls command to return a list of files containing "PRO" in its file name and belong to pli file type. I have researched and identified that ls -c -lt *.PLI will return a files of ".pli" type and ls -c -lt *PRO* will return file which has PRO in its file name.

Example: If folder contain aaaaaPROaaaaa.PLI, aaaaaPROaaaaa.PSO, aaaaaPROaaaaa.txt, bbbbbPRObb.PLI and bbbbbPRObb.txt, then I need to ls command to return only aaaaaPROaaaaa.PLI and bbbbbPRObb.PLI

If it is not achievable through ls command can we achieve it through find command ?

share|improve this question
up vote 4 down vote accepted

With ls, you can do:

ls -c -ltd -- *PRO*.PLI

With find:

find . ! -name . -prune -type f -name '*PRO*.PLI'

(note that find will include hidden files like .xPRO.PLI while the shell glob (*PRO*.PLI) will not by default).

share|improve this answer
Gnouc: It is so simple.. I thought it will be more complex :-). Thanks a lot for your quick solution. – Dinesh Kumar Aug 7 '14 at 5:40
Out of curiosity, why prune everything rather than -maxdepth 1? – BroSlow Aug 11 '14 at 4:51
prune is defined by POSIX, -maxdepth 1 not. – cuonglm Aug 11 '14 at 4:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.